Oracle DBA, How To, Error, Cause and Action

Automatically Open PDBs When CDB started

To automatically open PDB when CDB is started, we can use trigger at CDB level.

1. Login to CDB root

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

SQL> CREATE TRIGGER open_pdb3
  2  AFTER STARTUP ON DATABASE
  3  BEGIN
  4  EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE pdb3 OPEN';
  5  END open_pdb3;
  6  /

Trigger created.

2. Test it 

[oracle@ora12cn1 Desktop]$ srvctl stop database -d ora12c
[oracle@ora12cn1 Desktop]$ srvctl start database -d ora12c
[oracle@ora12cn1 Desktop]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Tue Dec 10 17:53:27 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

SQL> select name, open_mode from v$pdbs;

NAME                         OPEN_MODE
------------------------------ ----------
PDB$SEED                      READ ONLY
PDB2                          MOUNTED
PDB3                          READ WRITE
PDB3_CLONE                    MOUNTED

No comments:

Post a Comment

Thanks for your comment.