Start and stop the Pluggable & Container Database

Start and stop the Pluggable & Container Database

Start and stop the pluggable & container database.

1. Check the current session container.
Note: I am login in CDB$ROOT container.

SQL> show con_name
CON_NAME
--------------
CDB$ROOT

Start and Stop pluggable database
You should login in the pluggable or CDB$ROOT container. PDB shutdown can be managed from CDB$ROOT or by own PDB login.
First step we will explain from CDB$ROOT connectivity.
Second step will explain from direct PDB connectivity.

1. From CDB$ROOT container

-- Check status from CDB$ROOT
col name for a10
Select name,open_mode from v$pdbs;

NAME       OPEN_MODE
---------- ----------
PDB$SEED   READ ONLY
XEPDB1     READ WRITE
PDB2       READ WRITE

--Shutdown the PDB2 database
alter pluggable database PDB2 close immediate;
Pluggable database altered.

---Note: Shutdown change OPEN_MODE value to MOUNTED.

--Start the PDB2 database
alter pluggable database PDB2 open;
Pluggable database altered.

2. From PDB direct connectivity

--check you are in PDB
show con_name
CON_NAME
-----------------------
PDB2

--Shutdown the PDB2 database
shutdown immediate;
Pluggable Database closed.

--Start the PDB2 database
startup
Pluggable Database opened.

--Check status when PDB2 is open or connected in shutdown state it will give error "ORA-01219: database or pluggable database not open"
select name,open_mode from v$PDBS;

NAME       OPEN_MODE
---------- ----------
PDB2       READ WRITE

Start and Shutdown the container database
On SHUTDOWN the container database, it will close all the PDB then shutdown the CDB.
On STARTUP the container database only start the CDB$ROOT, you need to manually start the PDB database if you donot use the SAVESTATE feature.

-- For shutdown
Shutdown immediate

--For startup
startup

--Check status from v$PDBS
SQL> select name,open_mode from v$PDBS;

NAME       OPEN_MODE
---------- ----------
PDB$SEED   READ ONLY
XEPDB1     READ WRITE
PDB2       MOUNTED
PDB3       MOUNTED

For open all PDB you have to fire one command:

-- start all pluggable database
alter pluggable database all open;

--close all pluggable database
alter pluggable database all close;

Note: You see one XEPDB1 is already started because it is using save state functionality for PDBS.

col con_name for a10
col instance_name for a10
select con_name,instance_name,state from dba_PDB_saved_states;

CON_NAME   INSTANCE_N STATE
---------- ---------- --------------
XEPDB1     xe         OPEN

--Save current open state of PDB2, When CDB reboot it will pick the save state and make PDB2 open during startup.
alter pluggable database PDB2 save state;
Pluggable database altered.

--Check the current saved state configured.
select con_name,instance_name,state from dba_PDB_saved_states;

CON_NAME   INSTANCE_N STATE
---------- ---------- --------------
XEPDB1     xe         OPEN
PDB2       xe         OPEN

-- Remove from the saved state
alter pluggable database PDB2 discard state;
Pluggable database altered.

-- Check current value

select con_name,instance_name,state from dba_PDB_saved_states;
CON_NAME   INSTANCE_N STATE
---------- ---------- --------------
XEPDB1     xe         OPEN

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.