UNPLUG THE PDB ORACLE MULTITENANT
Check the existing PDB
kIsH@Xhydra<> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ZXPDB1 MOUNTED
4 ZXPDB2 MOUNTED
5 ZXPDB3 MOUNTED
6 ZXPDB4 MOUNTED
7 ZXPDB5 READ WRITE NO
Login to the PDB
kIsH@Xhydra<> alter session set container=ZXPDB5;
Session altered.
Just verify the container name
kIsH@Xhydra<> show con_name
CON_NAME
------------------------------
ZXPDB5
Login to the root CDB
kIsH@Xhydra<> alter session set container=CDB$ROOT;
Session altered.
Check the datafiles
kIsH@Xhydra<>select file_name,file_id,tablespace_name from cdb_data_files;
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------
/apps01/oradata/DB9ZX/datafile/o1_mf_system_k1ovsd5w_.dbf
1 SYSTEM
/apps01/oradata/DB9ZX/datafile/o1_mf_sysaux_k1ovthcc_.dbf
3 SYSAUX
/apps01/oradata/DB9ZX/datafile/o1_mf_undotbs1_k1ovtyhw_.dbf
4 UNDOTBS1
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------
/apps01/oradata/DB9ZX/datafile/o1_mf_users_k1ovtzls_.dbf
7 USERS
Close the PDB which should be unplugged
kIsH@Xhydra<> alter pluggable database ZXPDB5 close immediate;
Pluggable database altered.
Unplug the PDB to an XML file. In your case, it is better to save XML file in a safer location if not temp!
kIsH@Xhydra<> alter pluggable database ZXPDB5 unplug into '/tmp/ZXPDB5.xml';
Pluggable database altered.
let’s have a peek into the XML file. This file contains all metadata information about the PDB dbid, tablespaces and datafile location.
<PDB>
<xmlversion>1</xmlversion>
<pdbname>ZXPDB5</pdbname>
<cid>7</cid>
<byteorder>1</byteorder>
<vsn>318767104</vsn>
<vsns>
<vsnnum>19.0.0.0.0</vsnnum>
<cdbcompt>19.0.0.0.0</cdbcompt>
<pdbcompt>19.0.0.0.0</pdbcompt>
<vsnlibnum>0.0.0.0.24</vsnlibnum>
<vsnsql>24</vsnsql>
<vsnbsv>8.0.0.0.0</vsnbsv>
</vsns>
<dbid>2859338766</dbid>
<ncdb2pdb>0</ncdb2pdb>
<cdbid>1003433397</cdbid>
<guid>D8FBA9D39D7415F1E055000000000001</guid>
<uscnbas>2387160</uscnbas>
<uscnwrp>0</uscnwrp>
<undoscn>280</undoscn>
<rdba>4194824</rdba>
<tablespace>
<name>SYSTEM</name>
<type>0</type>
<tsn>0</tsn>
<status>1</status>
<issft>0</issft>
<isnft>0</isnft>
<encts>0</encts>
<flags>0</flags>
<bmunitsize>8</bmunitsize>
<file>
<path>/apps01/oradata/DBZXPDB5system_k1owybbn_.dbf</path>
Drop the PDB and say keep datafiles to persist the datafiles without removal
kIsH@Xhydra<> drop pluggable database ZXPDB5 keep datafiles;
Pluggable database dropped.
Validate the existence of dropped PDB
SQL> def pdbview=cdb_pdbs
SQL> def pdbcol='pdb_id,pdb_name,status'
SQL> def pdbname="pdb_name='ZXPDB5'"
SQL> select &pdbcol
2 from &pdbview
3 where &pdbname;
no rows selected
kIsH@Xhydra<>
set serveroutput on
DECLARE
compatible BOOLEAN := FALSE;
BEGIN
compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/tmp/ZXPDB5.xml');
if compatible then
DBMS_OUTPUT.PUT_LINE('Is pluggable PDB1 compatible? YES');
else DBMS_OUTPUT.PUT_LINE('Is pluggable PDB1 compatible? NO');
end if;
END;
/kIsH@Xhydra<>kIsH@Xhydra<> 2 3 4 5 6 7 8 9 10 11
Is pluggable PDB1 compatible? YES
PL/SQL procedure successfully completed.
References – (Pdb Plug and Unplug Document, n.d.)