Oracle Database 12c: How to unplug a pdb and plug it back into the same cdb
http://dbaworkshop.blogspot.com/2013/08/How-to-unplug-a-PDB-and-plug-it-back-into-the-same-CDB.html
Oracle Database 12c: How to unplug a pdb and plug it back into the same cdb
1. Articles from Database administrator
workshop
How to unplug a PDB and plug it back into the same
CDB
You have just unplugged a PDB and want to know how to eventually plug it back into
the same container.
Let's assume I have a pluggable database named PDB003 and I am just able to
unplug it using the following commands:
view plainprint?
1. SQL> alter pluggable database pdb003 close immediate;
2.
3. Pluggable database altered.
4.
5. SQL> alter pluggable database PDB003 unplug into '/app/oracle/oradata/pdb003.xml';
6.
7. Pluggable database altered.
If you query the CDB_PDBS view you can receive useful information about all PDBs
contained: id, name, unique identifiers, SCN at the time of creation and the status.
The STATUS column has several values:
NEW, the pdb has been created but never opened
NORMAL, pdb available to be used
UNPLUGGED, the pdb has been unplugged
NEEDS UPGRADE, the pdb must be upgraded
CONVERTING, a non-CDB is going to be converted into a pdb
UNUSABLE, the pdb cannot be used (creation in progress)
In my case the PDB003 pluggable database is in an UNPLUGGED status as
expected:
view plainprint?
1. SQL> select * from CDB_PDBS;
2.
3. PDB_ID PDB_NAME DBID CON_UID GUID STATUS CREATION_SCN CON_ID
4. ---------- ---------- ---------- ---------- -------------------------------- ------------- -----------
- ----------
5. 2 PDB$SEED 4063489868 4063489868 E19363E52C005C9AE045000000000001 NORMAL 233 1
6. 3 PDB001 1701599811 1701599811 E1F26215682E1142E045000000000001 NORMAL 1821405 1
7. 4 PDB002 1497027100 1497027100 E1F329ECE0F411E6E045000000000001 NORMAL 1844390 1
8. 5 PDB003 1448206714 1448206714 E2B9BE56B8B936CEE045000000000001 UNPLUGGED 1997215 1
To plug again the pluggable database PDB003 inside the original container
(CDB001) you cannot use a syntax like: ALTER PLUGGABLE DATABASE ...
PLUG (it doesn't exist in the "SQL Language Reference" manual a PLUG clause) ...
view plainprint?
1. SQL> alter pluggable database PDB003 plug;
2. alter pluggable database PDB003 plug
3. *
4. ERROR at line 1:
5. ORA-00922: missing or invalid option
... neither you can simply use CREATE PLUGGABLE DATABASE ... USING ...
view plainprint?
1. SQL> create pluggable database PDB003 using '/app/oracle/oradata/pdb003.xml' nocopy tempfile reuse;
2. create pluggable database PDB003 using '/app/oracle/oradata/pdb003.xml' nocopy tempfile reuse
3. *
4. ERROR at line 1:
5. ORA-65012: Pluggable database PDB003 already exists.
2. You need first to drop the pluggable database (DROP PLUGGABLE DATABASE
command) and then create it again (CREATE PLUGGABLE DATABASE
command).
In this way the pluggable database is plugged again into the same CDB and using
the same PDB name.
Have a look at the following commands:
view plainprint?
1. SQL> drop pluggable database PDB003;
2.
3. Pluggable database dropped.
4.
5. SQL> create pluggable database PDB003 using '/app/oracle/oradata/pdb003.xml' nocopy;
6.
7. Pluggable database created.
8.
9. SQL> select PDB_NAME, STATUS from CDB_PDBS;
10.
11. PDB_NAME STATUS
12. ---------- -------------
13. PDB$SEED NORMAL
14. PDB001 NORMAL
15. PDB002 NORMAL
16. PDB003 NEW
17.
18. SQL> alter session set container=PDB003;
19.
20. Session altered.
21.
22. SQL> alter database open;
23.
24. Database altered.
25.
26. SQL> select count(*) from marcov.T1;
27.
28. COUNT(*)
29. ----------
30. 100
Have a look again at the CDB_PDBS view and note the differences compared with
the previous results.
All the unique identifiers of PDB003 have been recreated.
view plainprint?
1. SQL> select * from CDB_PDBS;
2.
3. PDB_ID PDB_NAME DBID CON_UID GUID STATUS CREATION_SCN CON_ID
4. ---------- ---------- ---------- ---------- -------------------------------- ------------- -----------
- ----------
5. 2 PDB$SEED 4063489868 4063489868 E19363E52C005C9AE045000000000001 NORMAL 233 1
6. 3 PDB001 1701599811 1701599811 E1F26215682E1142E045000000000001 NORMAL 1821405 1
7. 4 PDB002 1497027100 1497027100 E1F329ECE0F411E6E045000000000001 NORMAL 1844390 1
8. 5 PDB003 1448206714 1448206714 E2B9BE56B8B936CEE045000000000001 NORMAL 3110422 1
That's all.