Oracle 12c: AFTER STARTUP trigger to open PDBs
Update: Starting with Oracle 12.1.0.2, it is possible to save a PDB state so this workaround is no longer necessary.
When starting up an Oracle 12c database with pluggable databases, the pluggable databases in a container database are not automatically opened, just placed in MOUNT mode. This can be a problem in some cases.
To automatically open the pluggable databases on startup, you’ll have to create an AFTER STARTUP
trigger in the CDB. For my own reference, I will post such a trigger here:
CREATE TRIGGER open_all_pdbs
AFTER STARTUP ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';
END open_all_pdbs;
/