Search this Blog

Tuesday, May 22, 2018

Automatic opening pluggable databases

When upgrading more and more databases from Oracle 11.2 to Oracle 12c we build more and more databases with the 12c CDB model.
Single Instande user databases have been converted to Pluggable DataBases ( PDB).
To make working with CDB's and PDB's easier, Oracle created an option to automatically open the PDB's as soon as the CDB is opened.
This save lots of work and makes automatic restarts from scripts easier.

To achieve this, the state of a PDB can be saved, so that the CDB knows which PDB to open after a startup.
The command to save this state is to be run from the PDB, so assuming that we have a CDB called ORACDB and a PDB called PLUG1, the command to execute would be:


$ export ORACLE_SID=ORACDB
$ sqlplus / as sysdba

SQL> alter pluggable database plug1 open;
SQL> alter session set container=plug1;
SQL> alter plugguble database plug1 save state;


Now, as soon as the CDB is started, the PDB is immediately accessible through the Listener.