Wednesday, 9 August 2017

PDB Auto start with CDB in 12c

[oracle@jdedb01 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.2.0 Production on Wed Aug 9 20:27:25 2017
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 8053063680 bytes
Fixed Size                  3729840 bytes
Variable Size            1879049808 bytes
Database Buffers         6157238272 bytes
Redo Buffers               13045760 bytes
Database mounted.
Database opened.
SQL> select name,open_mode from v$pdbs;
NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
JDEORCL                        MOUNTED

SQL> alter pluggable database all open;
Pluggable database altered.

SQL> select name,open_mode from v$pdbs;
NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
JDEORCL                        READ WRITE

SQL> alter pluggable database JDEORCL save state;
Pluggable database altered.

SQL> select CON_ID,CON_NAME,INSTANCE_NAME,STATE from dba_pdb_saved_states;
    CON_ID CON_NAME   INSTANCE_NAME      STATE
---------- ---------- ------------------ --------------
         3 JDEORCL    ORA12C             OPEN

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 8053063680 bytes
Fixed Size                  3729840 bytes
Variable Size            1879049808 bytes
Database Buffers         6157238272 bytes
Redo Buffers               13045760 bytes
Database mounted.
Database opened.
SQL> select name,open_mode from v$pdbs;
NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
JDEORCL                        READ WRITE


Note:
Set restart of specific database
altar pluggable database pdb_name save state;

Restart of all PDB’s :
altar pluggable database all save state;

we use this to keep the state of all but a few with the except clause:

altar pluggable database all except pdb_name1, pdb_name2 save state;