利用模板创建pdb 1、 利用语句查询出cdb与pdb的数据文件对应关系: SQL> 1 1* select NAME from v$datafile SQL> NAME -------------------------------------------------- /u01/app/oracle/oradata/PROD/system01.dbf /u01/app/oracle/oradata/PROD/sysaux01.dbf /u01/app/oracle/oradata/PROD/undotbs01.dbf /u01/app/oracle/oradata/PROD/pdbseed/system01.dbf /u01/app/oracle/oradata/PROD/pdbseed/sysaux01.dbf /u01/app/oracle/oradata/PROD/users01.dbf /u01/app/oracle/oradata/PROD/pdbseed/undotbs01.dbf /u01/app/oracle/oradata/PROD/pdb3/system01.dbf /u01/app/oracle/oradata/PROD/pdb3/sysaux01.dbf /u01/app/oracle/oradata/PROD/pdb3/undotbs01.dbf /u01/app/oracle/oradata/PROD/pdb3/users01.dbf /u01/app/oracle/oradata/PROD/pdb/system01.dbf /u01/app/oracle/oradata/PROD/pdb/sysaux01.dbf /u01/app/oracle/oradata/PROD/pdb/undotbs01.dbf /u01/app/oracle/oradata/PROD/pdb/users01.dbf /u01/app/oracle/oradata/PROD/pdb2/system01.dbf /u01/app/oracle/oradata/PROD/pdb2/sysaux01.dbf /u01/app/oracle/oradata/PROD/pdb2/undotbs01.dbf /u01/app/oracle/oradata/PROD/pdb2/users01.dbf 19 rows selected. 然后根据上面的路径设置新的pdb的路径对应关系 等: CREATE PLUGGABLE DATABASE cndbapdb ADMIN USER cndbaadm IDENTIFIED BY testpwd ROLES=(DBA) STORAGE (MAXSIZE 2G) DEFAULT TABLESPACE cndba DATAFILE '/u01/app/oracle/oradata/PROD/cndbapdb/cndba01.dbf' SIZE 100M AUTOEXTEND ON PATH_PREFIX = '/u01/app/oracle/oradata/PROD/' FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/PROD/pdbseed','/u01/app/oracle/oradata/PROD/cndbapdb'); 上面是创建了一个名为cndbapdb的PDB,创建一个cndbaadm管理用户并赋PDB_DBA权限,限制PDB可以使用空间大小为2G,创建表空间为cndba并设置为默认表空间。 SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB3 MOUNTED 4 CNDBAPDB MOUNTED 6 PDB READ WRITE NO 8 PDB2 MOUNTED SQL> select file#,name,con_id from v$datafile; SQL> select file#,name,con_id from v$datafile; FILE# NAME CON_ID ---------- -------------------------------------------------- ---------- 1 /u01/app/oracle/oradata/PROD/system01.dbf 1 3 /u01/app/oracle/oradata/PROD/sysaux01.dbf 1 4 /u01/app/oracle/oradata/PROD/undotbs01.dbf 1 5 /u01/app/oracle/oradata/PROD/pdbseed/system01.dbf 2 6 /u01/app/oracle/oradata/PROD/pdbseed/sysaux01.dbf 2 7 /u01/app/oracle/oradata/PROD/users01.dbf 1 8 /u01/app/oracle/oradata/PROD/pdbseed/undotbs01.dbf 2 33 /u01/app/oracle/oradata/PROD/pdb3/system01.dbf 3 34 /u01/app/oracle/oradata/PROD/pdb3/sysaux01.dbf 3 35 /u01/app/oracle/oradata/PROD/pdb3/undotbs01.dbf 3 36 /u01/app/oracle/oradata/PROD/pdb3/users01.dbf 3 45 /u01/app/oracle/oradata/PROD/pdb/system01.dbf 6 46 /u01/app/oracle/oradata/PROD/pdb/sysaux01.dbf 6 47 /u01/app/oracle/oradata/PROD/pdb/undotbs01.dbf 6 48 /u01/app/oracle/oradata/PROD/pdb/users01.dbf 6 53 /u01/app/oracle/oradata/PROD/pdb2/system01.dbf 8 54 /u01/app/oracle/oradata/PROD/pdb2/sysaux01.dbf 8 55 /u01/app/oracle/oradata/PROD/pdb2/undotbs01.dbf 8 56 /u01/app/oracle/oradata/PROD/pdb2/users01.dbf 8 81 /u01/app/oracle/oradata/PROD/cndbapdb/system01.dbf 4 82 /u01/app/oracle/oradata/PROD/cndbapdb/sysaux01.dbf 4 83 /u01/app/oracle/oradata/PROD/cndbapdb/undotbs01.dbf 4 22 rows selected.