We will explain Oracle PDB Automatic Startup in 12c in this article.
STEP 1 :- Check The List Of PDBS . Here In My case NAWAZDB1 and NAWAZDB2 are the PDBS
1 2 3 4 5 6 7 | SELECT name, open_mode FROM v$pdbs; NAME OPEN_MODE ------------------------------ ---------- PDB$SEED READ ONLY NAWAZDB1 READ WRITE NAWAZDB2 READ WRITE |
STEP 2 :-
1 2 | SHUTDOWN IMMEDIATE; STARTUP; |
STEP 3 :- Check the Open_mode of the PDBS . Here You will see the PDBS in Mount State
1 2 3 4 5 6 7 | SELECT name, open_mode FROM v$pdbs; NAME OPEN_MODE ------------------------------ ---------- PDB$SEED READ ONLY NAWAZDB1 MOUNTED NAWAZDB2 MOUNTED |
STEP 4 :- Change the State Of PDB
Let us now open the 2 PDBS, and save the state of NAWAZDB1 to save
1 2 3 | ALTER PLUGGABLE DATABASE NAWAZDB1 OPEN; ALTER PLUGGABLE DATABASE NAWAZDB2 OPEN; ALTER PLUGGABLE DATABASE NAWAZDB1 SAVE STATE; |
Now you can check the DBA_PDB_SAVED_STATES view :-
Here it shows the entry of NAWAZDB1 as shown below :-
1 2 3 4 5 6 7 | SELECT con_name, instance_name, state FROM dba_pdb_saved_states; CON_NAME INSTANCE_NAME STATE -------------------- -------------------- -------------- NAWAZDB1 cdb1 OPEN SQL> |
Check the Database Open Mode :-
1 2 3 4 5 6 7 8 9 | SELECT name, open_mode FROM v$pdbs; NAME OPEN_MODE ------------------------------ ---------- PDB$SEED READ ONLY NAWAZDB1 READ WRITE NAWAZDB2 READ WRITE SQL> |
STEP 5 :-
1 2 | SHUTDOWN IMMEDIATE; STARTUP; |
Now You will see that the NAWAZDB1 is in READ WRITE MODE where as the NAWAZDB2 is in Mount State
1 2 3 4 5 6 7 8 9 | SELECT name, open_mode FROM v$pdbs; NAME OPEN_MODE ------------------------------ ---------- PDB$SEED READ ONLY NAWAZDB1 READ WRITE NAWAZDB2 MOUNTED SQL> |
Well Thats it, every time you restart your database you will now be able to see NAWAZDB1 in read/write mode .
Similary You can discard this change If you want to start the PDB manually everytime you bounce the Instance .
STEP 1 :-
1 2 3 4 5 6 7 | ALTER PLUGGABLE DATABASE NAWAZDB1 DISCARD STATE; SELECT con_name, instance_name, state FROM dba_pdb_saved_states; no rows selected SQL> |
STEP 2 :-
1 2 3 4 5 6 7 8 9 10 | SHUTDOWN IMMEDIATE; STARTUP; SELECT name, open_mode FROM v$pdbs; NAME OPEN_MODE ------------------------------ ---------- PDB$SEED READ ONLY NAWAZDB1 MOUNTED NAWAZDB2 MOUNTED |