Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

How To Open The PDBS Automatically When CDB Restarts | Save State of PDBS

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarKiran Dalvi
  • 23 Sep, 2020
  • 0 Comments
  • 1 Min Read

How To Open The PDBS Automatically When CDB Restarts | Save State of PDBS

In oracle 12c , when we startup the CDB, the PDBS will be in MOUNTED stage. We need to open them manually using alter pluggable PDB open. To make the PDBS open automatically, we can use the saved state option . This feature is available from Oracle 12.1.0.2  onwards 

Start the container database and you will find that all PDBS are in mount stage.

[oracle@prim ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Sep 23 14:47:49 2020

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1140850688 bytes
Fixed Size 8791960 bytes
Variable Size 805308520 bytes
Database Buffers 318767104 bytes
Redo Buffers 7983104 bytes
Database mounted.
Database opened.
SQL>


SQL> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBPRIM MOUNTED
4 PDBPRIM2 MOUNTED
5 PDBPRIM4 MOUNTED
6 PDBPRIM5 MOUNTED
SQL>

Connect to the pluggable database and start the pluggable database.

SQL> alter session set container=PDBPRIM;

Session altered.

SQL> startup
Pluggable Database opened.

Connect to Container database and save the state.

SQL> alter session set container=CDB$ROOT;

Session altered.

SQL>
SQL>
SQL> alter pluggable database PDBPRIM save state;

Pluggable database altered.


Verify the state with view dba_pdb_saved_states.

SQL> select con_name, state from dba_pdb_saved_states;

CON_NAME STATE
--------------- --------------
PDBPRIM OPEN


Bounce the container database and verify pluggable database should be in open mode.

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


SQL> startup
ORACLE instance started.

Total System Global Area 1140850688 bytes
Fixed Size 8791960 bytes
Variable Size 805308520 bytes
Database Buffers 318767104 bytes
Redo Buffers 7983104 bytes
Database mounted.
Database opened.

SQL> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBPRIM READ WRITE NO
4 PDBPRIM2 MOUNTED
5 PDBPRIM4 MOUNTED
6 PDBPRIM5 MOUNTED

We can discard the state of pluggable database with following command.

SQL> alter pluggable database PDBPRIM discard state;

Pluggable database altered.


SQL> shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.


SQL> startup
ORACLE instance started.

Total System Global Area 1140850688 bytes
Fixed Size 8791960 bytes
Variable Size 805308520 bytes
Database Buffers 318767104 bytes
Redo Buffers 7983104 bytes
Database mounted.
Database opened.


SQL> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBPRIM MOUNTED
4 PDBPRIM2 MOUNTED
5 PDBPRIM4 MOUNTED
6 PDBPRIM5 MOUNTED