--View PDB information (in CDB mode)
show pdbs --查看所有pdbselect name,open_mode from v$pdbs; --v$pdbs为PDB信息视图select con_id, dbid, guid, name , open_mode from v$pdbs;
--Switch container
alter session set container=orcl1 --切换到PDBorcl1容器alter session set container=CDB$ROOT --切换到CDB容器
--See which container is currently belonging
select sys_context(‘USERENV‘,‘CON_NAME‘) from dual; --使用sys_context查看属于哪个容器show con_name --用show查看当前属于哪个容器
--Start PDB
alter pluggable database orcl1 open; --开启指定PDBalter pluggable database all open; --开启所有PDBalter session set container=orcl1; --切换到PDB进去开启数据库startup
--Close PDB
alter pluggable database orcl1 close; --关闭指定的PDBalter pluggable database all close; --关闭所有PDBalter session set container=orcl1; --切换到PDB进去关闭数据库shutdown immediate
--Specify the location of the file map before creating or cloning (requires SYSDBA permissions in the CBD)
alter system set db_create_file_dest=‘/u01/app/oracle/oradata/orcl/orcl2‘;
--Create a new PDB: (Requires SYSDBA permissions under CBD)
create pluggable database test admin user admin identified by admin; alter pluggable database test_pdb open; --将test_pdb 打开
--Clone PDB (requires SYSDBA permissions under CBD)
create pluggable database orcl2 from orcl1; --test_pdb必须是打开的,才可以被打开alter pluggable database orcl2 open; --然后打开这个pdb
--Remove PDB (requires SYSDBA permissions under CBD)
alter pluggable database orcl2 close; --关闭之后才能删除drop pluggable database orcl2 including datafiles; --删除PDB orcl2
--Set the CDB start PDB to start automatically (using a trigger here)
CREATE OR REPLACE TRIGGER open_pdbsAFTER STARTUP ON DATABASEBEGINEXECUTE IMMEDIATE ‘ALTER PLUGGABLE DATABASE ALL OPEN‘;END open_pdbs;/
Oracle 12C CDB, PDB common management commands