//开启数据库
sqlplus / as sysdba; //登录连接CDB,默认是root container;
startup; //open 模式,但此时的pdb模式是mounted,需要手工开启
alter session set container=testpdb1; //切换到某个pdb
alter pluggable database open; //开启选定的pdb
alter pluggable database all open; //开启全部pdb
//关闭数据库
alter pluggable database all close; //关闭所有dpb
alter session set container=testpdb1; //切换到某个pdb
shutdown immediate;
alter session set container = CDB$ROOT; //切换到cdb
shutdown immediate;
可以通过添加Trigger的形式来客制化startup时自动将PDB OPEN
使用SYS用户创建如下触发器即可:
CREATE TRIGGER open_all_pdbs
AFTER STARTUP
ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'alter pluggable database all open';
END open_all_pdbs;