12c可插拔数据库CDB与PDB管理总结
12c可插拔数据库CDB与PDB管理总结
创建pdb
1、直接创建
1 CREATE PLUGGABLE DATABASE pdb2 2 ADMIN USER boswll IDENTIFIED BY oracle 3 STORAGE (MAXSIZE 2G MAX_SHARED_TEMP_SIZE 100M) 4 DEFAULT TABLESPACE test DATAFILE '/opt/oracle/oradata/orcl/datafile/test_001.dbf' SIZE 25M AUTOEXTEND ON;
2、以现有pdb为模板创建
现有pdb必须在read only模式下才能被创建,否则报错
以pdb1为模板创建pdb2
1 alter pluggable database pdb2 close immediate; 2 drop pluggable database pdb2 including datafiles; 3 alter pluggable database pdb1 close; 4 alter pluggable database pdb1 open read only; 5 create pluggable database pdb2 6 from pdb1 7 file_name_convert =('/opt/oracle/oradata/orcl/E98BEB85B1A80C56E0439A02A8C05841/datafile/','/opt/oracle/oradata/orcl/datafile/pdb2');
打开关闭pdb
1 alter pluggable database all open; 2 alter pluggable database pdb2 close; 3 alter pluggable database all close; 4 alter pluggable database pdb2 close immediate; 5 alter pluggable database pdb2 open; 6 alter pluggable database all open;
删除pdb
与删除表空间类似,可以级联删除数据文件
1 drop pluggable database pdb2; 2 drop pluggable database pdb2 including datafiles;
只是删除库,不删除文件
1 DROP PLUGGABLE DATABASE pdb2 KEEP DATAFILES;
1 保持启动CDB后PDB的状态 2 alter pluggable database all save state; 3 shut immediate; 4 startup 5 6 容器之间的切换 7 alter session set container=CDB$ROOT; 8 alter session set container=pdb5; 9 10 查看当前容器 11 show con_name 12 select sys_context('userenv', 'con_name') "Container DB" from dual; 13 14 查看pdb的信息 15 查看CDB中有多少个pluggable database 16 alter session set container=CDB$ROOT; 17 show pdbs 18 select con_id, dbid, guid, name , open_mode from v$pdbs;