环境:centos7、oracle12c
1、从PDB$SEED创建PDB 使用CREATE PLUGGABLE DATABASE
SQL> CREATE PLUGGABLE DATABASE PDB1 ADMIN USER pdb1user IDENTIFIED BY oracle FILE_NAME_CONVERT=(‘/u01/app/oracle/oradata/PDBSEED/‘,‘/u01/app/oracle/oradata/CDB1/PDB1/‘); --从pdbseed目录拷贝文件到新的pdb SQL> show pdbs --查看pad状态 CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 MOUNTED SQL> ALTER PLUGGABLE DATABASE PDB1 OPEN; --开启pdb Pluggable database altered. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO SQL> ALTER SESSION SET CONTAINER=PDB1; --从cdb进入到pdb Session altered. SQL> show con_name; CON_NAME ------------------------------ PDB1
2、克隆本地远程的PDB
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO SQL> ALTER PLUGGABLE DATABASE pdb1 CLOSE; SQL> ALTER PLUGGABLE DATABASE PDB1 OPEN READ ONLY; SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ ONLY NO SQL> CREATE PLUGGABLE DATABASE PDB2 FROM PDB1 FILE_NAME_CONVERT=(‘/u01/app/oracle/oradata/CDB1/PDB1/‘,‘/u01/app/oracle/oradata/CDB1/PDB2/‘); --从pdb1克隆pdb2 SQL> ALTER PLUGGABLE DATABASE PDB2 OPEN;
3、删除PDB
PDB删除必须处于mount状态 SQL> ALTER PLUGGABLE DATABASE PDB1 CLOSE IMMEDIATE; Pluggable database altered. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 MOUNTED SQL> DROP PLUGGABLE DATABASE PDB1 INCLUDING DATAFILES; --删除pdb