环境:
Oracle 12c , 多租户数据库
CDB1 test12 , 含有多个PDB: plugdb, mypdb1,mypdb2
CDB2 test12c, 也含有多个PDB: plugdb,mypdb1
要求:
现在要将test12 下的mypdb2拔出,插入到test12c这个CDB下(名称改为pdb2)。
1. 先close pdb,然后在$ORACLE_HOME/assistants/dbca/templates,生成一个xml文件描述pdb
原来文件的路径和scn等信息;
[oracle@gtsv2088r ~]$ . .bash_profile_12c_2
[oracle@gtsv2088r ~]$ env | grep ORA
ORACLE_SID=test12
ORACLE_BASE=/data01/oracle12c
ORACLE_HOME=/data01/oracle12c/oracle
[oracle@gtsv2088r ~]$
[oracle@gtsv2088r ~]$ sqlplus / as sysdba
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PLUGDB READ WRITE NO
4 CONT01_PLUG01 MOUNTED
5 MYPDB1 READ ONLY NO
6 MYPDB2 READ WRITE NO
SQL>
SQL> alter pluggable database mypdb2 close ;
Pluggable database altered.
SQL> alter pluggable database mypdb2 unplug into '/data01/oracle12c/oracle/assistants/dbca/templates/test12_mypdb2.xml';
Pluggable database altered.
2. 将pdb的文件拷贝到某个bak目录或直接拷贝(scp)到目标CDB的目录下。
[oracle@gtsv2088r test12]$ ls
arch control01.ctl mypdb1 mypdb2_bak plugdb redo02.log sysaux01.dbf temp01.dbf users01.dbf
cont01plug01 control02.ctl mypdb2 pdbseed redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@gtsv2088r test12]$ pwd
/data01/oracle12c/oradata/test12
[oracle@gtsv2088r test12]$
[oracle@gtsv2088r test12]$ cp -R mypdb2 mypdb2_bak