拔PDB可以参考文档:Unplugging a PDB from a CDB
Unplug a PDB with a ALTER PLUGGABLE DATABASE ... UNPLUG INTO statement.
Prerequisites
The following prerequisites must be met:
The current user must have SYSDBA or SYSOPER administrative privilege, and the privilege must be either commonly granted or locally granted in the PDB. The user must exercise the privilege using AS SYSDBA or AS SYSOPER at connect time.
The PDB must have been opened at least once.
Note:If you are unplugging a PDB that includes data that was encrypted with Transparent Data Encryption, then follow the instructions in Oracle Database Advanced Security Guide.
To unplug a PDB:
In SQL*Plus, ensure that the current container is the root of the PDB.
If the PDB is plugged into the CDB root, then the current container must be the CDB root. If the PDB is plugged into an application root, then the current container must be the application root.
If you are unplugging an application container, then the current container must be the CDB root, and the application container must not have any application PDBs plugged into it.
Close the PDB.
In an Oracle Real Application Clusters (Oracle RAC) environment, the PDB must be closed on all instances.
Run the ALTER PLUGGABLE DATABASE statement with the UNPLUG INTO clause, and specify the PDB to unplug and the name and location of the PDB's XML metadata file or .pdb file.
Example 11-1 Unplugging PDB salespdb Into an XML Metadata File
This ALTER PLUGGABLE DATABASE statement unplugs the PDB salespdb and creates the salespdb.xml metadata file in the /oracle/data/ directory:
ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/oracle/data/salespdb.xml';
Example 11-2 Unplugging PDB salespdb Into an Archive File
This ALTER PLUGGABLE DATABASE statement unplugs the PDB salespdb and creates the sales.pdb archive file in the /oracle/data/ directory. The sales.pdb archive file is a compressed file that includes the XML metadata file and the PDB’s files (such as the data files and wallet file).
ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/oracle/data/sales.pdb';
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB01 READ WRITE NO
4 PDB02 READ WRITE NO
把PDB02从容器中拔出
SQL> ALTER PLUGGABLE DATABASE PDB02 UNPLUG INTO '/home/oracle/PDB02.xml';
Pluggable database altered.
SQL>
SQL> select pdb_name,status from dba_pdbs;
PDB_NAME STATUS
------------------------------ ----------
PDB01 NORMAL
PDB$SEED NORMAL
PDB02 UNPLUGGED
被拔出的PDB无法open
SQL> alter PLUGGABLE DATABASE PDB02 open;
alter PLUGGABLE DATABASE PDB02 open
*
ERROR at line 1:
ORA-65086: cannot open/close the pluggable database
插回PDB可以参考:Plugging In an Unplugged PDB
使用PROD02.xml创建一个新的PDB,或者删除旧的PDB保留数据文件, 然后重新创建PDB
SQL> drop pluggable database PDB02 keep datafiles;
Pluggable database dropped.
SQL>
SQL> create pluggable database PDB02 as clone using '/home/oracle/PDB02.xml' nocopy tempfile reuse;
Pluggable database created.
SQL> alter pluggable database PDB02 open;
Pluggable database altered.
SQL>
或者创建一个新的PDB
SQL> create pluggable database PDB022 as clone using '/home/oracle/PDB02.xml' copy FILE_NAME_CONVERT = ('/oracle/app/oradata/PRODPDB02','/oracle/app/oradata/PRODPDB');
Pluggable database created.
SQL>