Oracle 12C CDB、PDB常用管理命令--查看PDB信息(在CDB模式下)show pdbs --查看所有pdbselect name,open_mode from v$pdbs; --v$pdbs为PDB信息视图select con_id,dbid,guid,name,open_mode from v$pdbs;--切换容器alter session set container=orcl1 --切换到PDBorcl1容器alter session set container=CDB$ROOT --切换到CDB容器--查看当前属于哪个容器select sys_context(‘USERENV‘,‘CON_NAME‘) from dual; --使用sys_context查看属于哪个容器show con_name --用show查看当前属于哪个容器--启动PDBalter pluggable database orcl1 open; --开启指定PDBalter pluggable database all open; --开启所有PDBalter session set container=orcl1; --切换到PDB进去开启数据库startup--关闭PDBalter pluggable database orcl1 close; --关闭指定的PDBalter pluggable database all close; --关闭所有PDBalter session set container=orcl1; --切换到PDB进去关闭数据库shutdown immediate--创建或克隆前要指定文件映射的位置(需要CBD下sysdba权限)alter system set db_create_file_dest=‘/u01/app/oracle/oradata/orcl/orcl2‘;--创建一个新的PDB:(需要CBD下sysdba权限)create pluggable database test admin user admin identified by admin; alter pluggable database test_pdb open; --将test_pdb 打开--克隆PDB(需要CBD下sysdba权限)create pluggable database orcl2 from orcl1; --test_pdb必须是打开的,才可以被打开alter pluggable database orcl2 open; --然后打开这个pdb--删除PDB(需要CBD下sysdba权限)alter pluggable database orcl2 close; --关闭之后才能删除drop pluggable database orcl2 including datafiles; --删除PDB orcl2--设置CDB启动PDB自动启动(在这里使用的是触发器)CREATE OR REPLACE TRIGGER open_pdbsAFTER STARTUP ON DATABASEBEGINEXECUTE IMMEDIATE ‘ALTER PLUGGABLE DATABASE ALL OPEN‘;END open_pdbs;/