Oracle 12c中如何自动启动PDB Pluggable Database
PDB Pluggable Database是12c的一个重要的新特性, 但是对于CDB中的PDB,默认启动CDB时不会将所有的PDB带起来,这样我们就需要手动alter pluggable database ALL OPEN;
[Oracle@clouds ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 12.1.0.2.0 Production on 星期四 3月 31 08:52:31 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
连接到:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL> alter pluggable database bidb1 open;
插接式数据库已变更。
SQL> alter pluggable database bidb2 open;
插接式数据库已变更。
SQL> select con_id,name,open_mode from v$pdbs;
CON_ID NAME OPEN_MODE
---------- ------------------------------ ----------
2 PDB$SEED READ ONLY
3 BIDB1 READ WRITE
4 BIDB2 READ WRITE
--或是直接启动所有pluggable数据库
SQL> alter pluggable database all open;
可以通过添加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;
/
这样,在oracle 12c database 的cdb启动后,pdb也会自动启动了。