{
  "date": "2015-12-15T21:50:48",
  "slug": "ocm-12c-preparation-transportable-tablespaces",
  "link": "https://www.dbi-services.com/blog/ocm-12c-preparation-transportable-tablespaces/",
  "title": {
    "rendered": "OCM 12c preparation: Transportable Tablespaces"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.<br />\nI use transportable tablespaces a lot since 8i, here are just a few examples.<br />\nSame disclaimer here as in the first post of the series: don’t expect to get those posts close to what you will have at the exam, but they cover important points that matches the exam topics.</p>\n<h3>Documentation</h3>\n<p>Information about the exam says: <i>Create a plugged-in tablespace by using the transportable tablespace feature</i>. this is the TTS feature we know for a long time. The &#8216;plugged-in&#8217; term is how it was originally called (see patent: <a href=\"http://www.google.tl/patents/US5890167\" target=\"_blank\" rel=\"noopener noreferrer\">http://www.google.tl/patents/US5890167</a> from 1997). When 12c came with pluggable database, I said that it was just an extension of the TTS feature where the SYSTEM tablespace can be transported as well, thanks to multitenant architecture that separates application dictionary.<br />\nWhat&#8217;s new in 12c is the ability to transport a whole database, which means use TTS for all non-system tablespaces.<br />\nSo about documentation, open the Oracle® Database Administrator&#8217;s Guide, search for &#8216;transport&#8217; and you have a whole chapter about transporting data. then go to: Transporting Database</p>\n<h3>Read only</h3>\n<p>I&#8217;ve a PDB pluggable database with some tablespaces and tables, and I set the user tablespace read-only;</p>\n<pre><code>\nsqlplus / as sysdba\ncreate pluggable database PDB admin user admin identified by admin file_name_convert=('/u01/app/oracle/oradata/pdbseed','/u02/app/oracle/oradata/PDB');\nalter pluggable database PDB open;\nalter session set container=PDB;\ngrant dba to DEMO identified by demo;\ncreate tablespace USERS datafile '/tmp/usersPDB.dbf' size 10M;\ncreate table DEMO.DEMO tablespace USERS as select current_timestamp ts from dual;\nalter tablespace USERS read only;\nquit\n</code></pre>\n<h3>Transport database</h3>\n<p>Then I create a new pluggable database from seed and create a database link to transport the tablespace into it:</p>\n<pre><code>\nsqlplus / as sysdba\ncreate pluggable database PDBNEW admin user admin identified by admin file_name_convert=('/u01/app/oracle/oradata/pdbseed','/u02/app/oracle/oradata/PDBNEW');\nalter session set container=PDBNEW;\nstartup\ncreate database link DBL_PDB connect to system identified by oracle using '//localhost/PDB';\ncreate directory TMP as '/tmp';\nquit\ncp /tmp/usersPDB.dbf /tmp/usersPDBNEW.dbf\nimpdp '\"sys/oracle@//localhost/PDBNEW as sysdba\"' network_link=DBL_PDB directory=TMP FULL=Y TRANSPORTABLE=always transport_datafiles=/tmp/usersPDBNEW.dbf\n</code></pre>\n<p>This is database transport. It&#8217;s just the possibility to use both FULL=Y and TRANSPORTABLE. I don&#8217;t like FULL imports because they bring some mess with pseudo system schemas. But with multitenant, what is in a PDB is only user schemas.</p>\n<h3>Transport tablespace</h3>\n<p>If I wanted to transport only the tablespace, I need to have the user created before:</p>\n<pre><code>\nsqlplus / as sysdba\nalter pluggable database PDBNEW close;\ndrop pluggable database PDBNEW including datafiles;\ncreate pluggable database PDBNEW admin user admin identified by admin file_name_convert=('/u01/app/oracle/oradata/pdbseed','/u02/app/oracle/oradata/PDBNEW');\nalter session set container=PDBNEW;\nstartup\ncreate database link DBL_PDB connect to system identified by oracle using '//localhost/PDB';\ncreate directory TMP as '/tmp';\ngrant dba to DEMO identified by demo;\nquit\nimpdp '\"sys/oracle@//localhost/PDBNEW as sysdba\"' network_link=DBL_PDB directory=TMP TRANSPORT_TABLESPACES=USERS transport_datafiles=/tmp/usersPDBNEW.dbf\n</code></pre>\n<p>This is the simple transport tablespace we know from a long time. Need to create the user, then all metadata is imported by data pump and data comes with the files. Here I used NETWORK_LINK because it&#8217;s the most simple, but everything is the same with a dumpfile. Need to copy datafiles with it to the target.<br />\nOn different endianness, RMAN can be used to convert. All is referenced in the &#8216;transporting data&#8217; chapter of documentation.</p>\n",
    "protected": false
  }
}
