DBA Hub

📋Steps in this guide1/1

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

oracle configurationintermediate
by OracleDba
15 views
1

Overview

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

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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

Comments (0)

Please to add comments

No comments yet. Be the first to comment!