一、需求
12c DB创建后,PDB如何跟随CDB一起启动!
二、参考
三、测试
12.2 DB test
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 C11PDB READ WRITE NO SQL> select con_name, state from dba_pdb_saved_states; no rows selected
SQL> ALTER PLUGGABLE DATABASE C11PDB SAVE STATE;
select con_name, state from dba_pdb_saved_states
CON_NAME STATE
------------------------------ ----------------------------
C11PDB OPEN
重启之后,确认PDB跟随CDB自启动
其它相关命令
取消PDB跟随CDB自启动
alter pluggable database HYDB discard state;
指定所有PDB跟随CDB自启动
ALTER PLUGGABLE DATABASE ALL SAVE STATE;
指定某些PDB跟随CDB自启动
ALTER PLUGGABLE DATABASE PDB1 , PDB2 SAVE STATE;
指定所有PDB(排除指定的部分PDB之外)跟随CDB自启动
ALTER PLUGGABLE DATABASE ALL EXCEPT PDB3, PDB4 SAVE STATE;
其它相关信息,如果是12.1 没有这个命令! 可以通过如下创建触发器解决问题!
How To Automate The Opening Of Pluggable Databases After The CDB Starts Up? (Doc ID 1585529.1) Oracle Database - Enterprise Edition - Version 12.1.0.1 and later Create a database startup trigger to open all pluggable databases. sqlplus / as sysdba create or replace trigger open_all_pdbs after startup on database begin execute immediate 'alter pluggable database all open'; end; / Or to selectively startup pluggable databases, use separate commands for each. create or replace trigger open_all_pdbs after startup on database begin execute immediate 'alter pluggable database MYCDB1 open'; execute immediate 'alter pluggable database MYCDB2 open'; end; /
注意:Oracle 12.2 dg环境主库设置后,dg也需要单独设置,不是同步主库的自启动!