{
  "date": "2016-11-08T18:58:48",
  "slug": "oracle-12cr2-multitenant-local-undo",
  "link": "https://www.dbi-services.com/blog/oracle-12cr2-multitenant-local-undo/",
  "title": {
    "rendered": "Oracle 12cR2 multitenant: Local UNDO"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.<br />\nPluggable Databases are supposed to be isolated, containing the whole of user data and metadata. This is the definition of dictionary separation coming with multitenant architecture: only system data and metadata are at CDB level. User data and metadata are in separate tablespaces belonging to the PDB.  And this is what makes the unplug/plug available: because PDB tablespaces contain everything, you can transport their datafiles from one CDB to another.<br />\nHowever, if they are so isolated, can you explain why</p>\n<ul>\n<li>You cannot flashback a PDB?</li>\n<li>You need an auxiliary instance for PDB Point-In-Time recovery?</li>\n<li>You need to put the PDB read-only before cloning it?</li>\n</ul>\n<p><!--more--><br />\nThere is something that is not contained in your PDB but is at CDB level, and which contains user data. The UNDO tablespace is shared:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLocalUndo001.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLocalUndo001.png\" alt=\"CaptureLocalUndo001\" width=\"888\" height=\"476\" class=\"alignnone size-full wp-image-10686\" /></a></p>\n<p>You cannot flashback a PDB because doing so requires to rollback the ongoing transactions at the time you flashback. Information was in UNDO tablespace at that time, but is not there anymore.</p>\n<p>It&#8217;s the same idea with Point-In-Time recovery of PDB. You need to restore the UNDO tablespace to get those UNDO records from the Point-In-Time. But you cannot restore it in place because it&#8217;s shared with other PDBs that need current information. This is why you need an auxiliary instance for PDBPITR in 12.1</p>\n<p>To clone a PDB cannot be done with ongoing transactions because their UNDO is not in the PDB. This is why it can be done only when the PDB is read-only.</p>\n<h3>12.2 Local UNDO</h2>\n<p>In 12.2 you can choose to have one UNDO tablespace per PDB, in local undo mode, which is the default in DBCA:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLocalUndo000.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLocalUndo000.png\" alt=\"CaptureLocalUndo000\" width=\"753\" height=\"244\" class=\"alignnone size-full wp-image-10687\" /></a></p>\n<p>With local undo PDBs are truly isolated even when opened with ongoing transactions:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLocalUndo002.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLocalUndo002.png\" alt=\"CaptureLocalUndo002\" width=\"876\" height=\"476\" class=\"alignnone size-full wp-image-10685\" /></a></p>\n<p>Look at the &#8216;RB segs&#8217; column from RMAN report schema:<br />\n<code><br />\n[oracle@OPC122 ~]$ rman target /<br />\n&nbsp;<br />\nRecovery Manager: Release 12.2.0.1.0 - Production on Tue Nov 8 18:53:46 2016<br />\n&nbsp;<br />\nCopyright (c) 1982, 2016, Oracle and/or its affiliates.  All rights reserved.<br />\n&nbsp;<br />\nconnected to target database: CDB1 (DBID=901060295)<br />\n&nbsp;<br />\nRMAN&gt; report schema;<br />\n&nbsp;<br />\nusing target database control file instead of recovery catalog<br />\nReport of database schema for database with db_unique_name CDB1<br />\n&nbsp;<br />\nList of Permanent Datafiles<br />\n===========================<br />\nFile Size(MB) Tablespace           RB segs Datafile Name<br />\n---- -------- -------------------- ------- ------------------------<br />\n1    880      SYSTEM               YES     /u02/app/oracle/oradata/CDB1/system01.dbf<br />\n3    710      SYSAUX               NO      /u02/app/oracle/oradata/CDB1/sysaux01.dbf<br />\n4    215      UNDOTBS1             YES     /u02/app/oracle/oradata/CDB1/undotbs01.dbf<br />\n5    270      PDB$SEED:SYSTEM      NO      /u02/app/oracle/oradata/CDB1/pdbseed/system01.dbf<br />\n6    560      PDB$SEED:SYSAUX      NO      /u02/app/oracle/oradata/CDB1/pdbseed/sysaux01.dbf<br />\n7    5        USERS                NO      /u02/app/oracle/oradata/CDB1/users01.dbf<br />\n8    180      PDB$SEED:UNDOTBS1    NO      /u02/app/oracle/oradata/CDB1/pdbseed/undotbs01.dbf<br />\n9    270      PDB1:SYSTEM          YES     /u02/app/oracle/oradata/CDB1/PDB1/system01.dbf<br />\n10   590      PDB1:SYSAUX          NO      /u02/app/oracle/oradata/CDB1/PDB1/sysaux01.dbf<br />\n11   180      PDB1:UNDOTBS1        YES     /u02/app/oracle/oradata/CDB1/PDB1/undotbs01.dbf<br />\n12   5        PDB1:USERS           NO      /u02/app/oracle/oradata/CDB1/PDB1/users01.dbf<br />\n&nbsp;<br />\nList of Temporary Files<br />\n=======================<br />\nFile Size(MB) Tablespace           Maxsize(MB) Tempfile Name<br />\n---- -------- -------------------- ----------- --------------------<br />\n1    33       TEMP                 32767       /u04/app/oracle/oradata/temp/temp01.dbf<br />\n2    64       PDB$SEED:TEMP        32767       /u04/app/oracle/oradata/temp/temp012016-10-04_11-34-07-330-AM.dbf<br />\n3    100      PDB1:TEMP            100         /u04/app/oracle/oradata/CDB1/PDB1/temp012016-10-04_11-34-07-330-AM.dbf<br />\n</code></p>\n<p>You have an UNDO tablespace in ROOT, in PDB$SEED and in each user PDB.</p>\n<p>If you have a database in shared undo mode, you can move to local undo mode while in &#8216;startup migrate&#8217;. PDBs when opened will have an UNDO tablespace created. You can also create an UNDO tablespace in PDB$SEED. </p>\n<p>Yes, in 12.2, you can open the PDB$SEED read/write for this purpose:</p>\n<p><code><br />\n18:55:59 SQL&gt; alter pluggable database PDB$SEED open read write force;<br />\n&nbsp;<br />\nPluggable database altered.<br />\n&nbsp;<br />\n18:56:18 SQL&gt; show pdbs;<br />\n&nbsp;<br />\n    CON_ID CON_NAME                       OPEN MODE  RESTRICTED<br />\n---------- ------------------------------ ---------- ----------<br />\n         2 PDB$SEED                       READ WRITE NO<br />\n         3 PDB1                           READ WRITE NO<br />\n18:56:23 SQL&gt; alter pluggable database PDB$SEED open read only force;<br />\n&nbsp;<br />\nPluggable database altered.<br />\n</code><br />\nBut remember this is only allowed for local undo migration.</p>\n<p>The recommandation is to run in local undo mode, even in Single-Tenant.</p>\n<p>More about it in the <a href=\"http://12cr2multitenant.pachot.net\">12cR2 Multitenant book</a>:<br />\n<a href=\"http://12cr2multitenant.pachot.net\"><img decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/51UkZp1tqGL._SX397_BO1204203200_.jpg\" alt=\"\" /></a></p>\n",
    "protected": false
  }
}
