q Concept started from 12c
q From 21c compulsory need to create a container
database [CDB]
q 18c or 19c You can use non-CDB [NON-CONTAINER]
q Two pluggable databases free of cost in Oracle
q Container database [CDB]: Only holds metadata information
v Parameter file will be available on container
database [CDB] level [This parameter will be shared between container &
pluggable database]
v All this background process on the container database
[CDB] level.
v Patching will be only container database and
shared with the pluggable database.
v Upgradation on container level then automatic upgrade in your pluggable database
q Pluggable database [PDB]: Actual user's data store
Ü CDB & PDB [ CONNECT | OPEN | CLOSE ]
q [oracle@dev ~]$ sqlplus / as sysdba
SQL*Plus: Release
19.0.0.0.0 - Production on Sun May 28 20:17:00 2023
Version 19.3.0.0.0
Copyright (c) 1982,
2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise
Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
q SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
q SQL> show pdbs
CON_ID CON_NAME
OPEN MODE RESTRICTED
---------- ------------------------------
---------- ----------
2 PDB$SEED
READ ONLY NO
3 DEVPDB MOUNTED
q SQL> alter session set container=DEVPDB;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
DEVPDB
q SQL> startup
Pluggable Database opened.
q SQL> show pdbs
CON_ID CON_NAME
OPEN MODE RESTRICTED
----------
------------------------------ ---------- ----------
3 DEVPDB READ WRITE NO
q SQL> shu immediate
Pluggable Database closed.
q SQL> show pdbs
CON_ID CON_NAME OPEN MODE
----------
------------------- -------------------
3 DEVPDB MOUNTED
q SQL> alter session set container=CDB$ROOT;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
q SQL> alter pluggable database devpdb open;
Pluggable database altered.
q SQL> show pdbs
CON_ID CON_NAME
OPEN MODE RESTRICTED
----------
------------------------------ ---------- ----------
2 PDB$SEED
READ ONLY NO
3 DEVPDB READ WRITE NO
q SQL> alter pluggable database DEVPDB close;
Pluggable database altered.
q SQL> show pdbs
CON_ID CON_NAME
OPEN MODE RESTRICTED
----------
------------------------------ ---------- ----------
2 PDB$SEED
READ ONLY NO
3 DEVPDB MOUNTED
q SQL> exit
Disconnected from
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
Ü HOW TO DIRECT CONNECT WITH PDB
q [oracle@dev ~]$ export ORACLE_PDB_SID=devpdb
q [oracle@dev ~]$ sqlplus / as sysdba
SQL*Plus: Release
19.0.0.0.0 - Production on Sun May 28 20:41:53 2023
Version 19.3.0.0.0
Copyright (c) 1982,
2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c
Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
q SQL> show con_name
CON_NAME
------------------------------
DEVPDB
Ü PARAMETER FILE | CONTROL FILES SHARED BETWEEN CONTAINER [CDB] & PLUGGABLE [PDB]
q PARAMETER FILE
q [oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0
- Production on Thu Feb 8 17:01:15 2024
Version 19.3.0.0.0
Copyright (c) 1982,
2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c
Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
q SQL> alter session set container=CDB$ROOT;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
q SQL> show parameter spfile;
NAME
TYPE VALUE
------------------------------------
----------- ------------------------------
spfile
string
/u01/app/oracle/product/19.0.0
/dbhome_1/dbs/spfiledevcdb.ora
q SQL> alter session set container=devpdb;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
DEVPDB
q SQL> show parameter spfile;
NAME
TYPE VALUE
------------------------------------
----------- ------------------------------
spfile
string
/u01/app/oracle/product/19.0.0
/dbhome_1/dbs/spfiledevcdb.ora
q CONTROL FILES
q [oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release
19.0.0.0.0 - Production on Thu Feb 8 17:01:15 2024
Version 19.3.0.0.0
Copyright (c) 1982,
2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise
Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
q SQL> alter session set container=CDB$ROOT;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
q SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEVCDB/control01.ctl
/u01/app/oracle/fast_recovery_area/DEVCDB/control02.ctl
q SQL> alter session set container=devpdb;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
DEVPDB
q SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEVCDB/control01.ctl
/u01/app/oracle/fast_recovery_area/DEVCDB/control02.ctl
Ü CDB & PDB HAVE THEIR OWN DATA FILES
q [oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release
19.0.0.0.0 - Production on Thu Feb 8 17:01:15 2024
Version 19.3.0.0.0
Copyright (c) 1982,
2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c
Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
q SQL> alter session set container=CDB$ROOT;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
q SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEVCDB/system01.dbf
/u01/app/oracle/oradata/DEVCDB/sysaux01.dbf
/u01/app/oracle/oradata/DEVCDB/undotbs01.dbf
/u01/app/oracle/oradata/DEVCDB/users01.dbf
q SQL> alter session set container=devpdb;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
DEVPDB
q SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEVCDB/devpdb/system01.dbf
/u01/app/oracle/oradata/DEVCDB/devpdb/sysaux01.dbf
/u01/app/oracle/oradata/DEVCDB/devpdb/undotbs01.dbf
/u01/app/oracle/oradata/DEVCDB/devpdb/users01.dbf
Ü REDOLOG FILES SHARED BETWEEN CONTAINER [CDB] & PLUGGABLE [PDB]
q [oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release
19.0.0.0.0 - Production on Thu Feb 8 17:01:15 2024
Version 19.3.0.0.0
Copyright (c) 1982,
2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c
Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
q SQL> alter session set container=CDB$ROOT;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
q SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEVCDB/redo03.log
/u01/app/oracle/oradata/DEVCDB/redo02.log
/u01/app/oracle/oradata/DEVCDB/redo01.log
q SQL> alter session set container=DEVPDB;
Session altered.
q SQL> show con_name
CON_NAME
------------------------------
DEVPDB
q SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEVCDB/redo03.log
/u01/app/oracle/oradata/DEVCDB/redo02.log
/u01/app/oracle/oradata/DEVCDB/redo01.log
Ü CREATE NEW PLUGGABLE DATABASE USING [dbca] PDB$SEED [TEMPLEATE]
q [oracle@dev ~]$ dbca
v Manage Pluggable database
v Create a Pluggable database
v Create a new Pluggable database from another
PDB
v PDB$SEED
v DEVPDB
v Pluggable database name: ORCLPDB
v Administrator user name: PDBADMIN
v Administrator password: oracle
v Confirm administrator password: oracle
Ü CREATE NEW PLUGGABLE DATABASE USING [command line] PDB$SEED [TEMPLEATE]
q [oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0
- Production on Thu Feb 8 17:01:15 2024
Version 19.3.0.0.0
Copyright (c) 1982,
2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c
Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
q SQL> alter session set container=PDB$SEED;
Session altered.
q SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/MAXCDB/pdbseed/system01.dbf
/u01/app/oracle/oradata/MAXCDB/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/MAXCDB/pdbseed/undotbs01.dbf
q SQL> alter session set container= CDB$ROOT;
q SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
q SQL> CREATE PLUGGABLE DATABASE orclpdb ADMIN USER pdbadmin IDENTIFIED BY oracle FILE_NAME_CONVERT=('/u01/app/oracle/oradata/MAXCDB/pdbseed/', '/u01/app/oracle/oradata/MAXCDB/orclpdb/');
Pluggable database created.
r SQL> CREATE PLUGGABLE DATABASE vdpdb FROM maxpdb FILE_NAME_CONVERT=('/u01/app/oracle/oradata/MAXCDB/maxpdb/','/u01/app/oracle/oradata/MAXCDB/vdpdb/');
Pluggable database created.
Ü Unplugging a PDB
q [oracle@dev ~]$ dbca
& Select the operation that you want to perform
v Manage Pluggable databases
& Select the operation that you want to perform in a Container database
v Unplug a Pluggable database
& Select Pluggable database [ORCLPDB]
v Generate Pluggable database file set
v Pluggable database metadata file
v Pluggable database datafile backup
Ü Plugging a PDB
q [oracle@dev ~]$ dbca
& Select the operation that you want to perform
q Manage Pluggable databases
& Select the operation that you want to perform in a Container database
q Create a Pluggable database
& Create Pluggable database from an unplugged PDB
q Create using the PDB file set
v Pluggable database metadata file | Browse [maxcdb_ORCLPDB.xml]
v Pluggable database datafile backup
Ü Delete Pluggable PDB
q [oracle@dev ~]$ dbca
& Select the operation that you want to perform
q Manage Pluggable databases
& Select the operation that you want to perform in a Container database
q Delete a Pluggable database
& Create Pluggable database from an unplugged PDB
q Select a Pluggable database
v Devpdb
& Delete Pluggable database Manually
q [oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release
19.0.0.0.0 - Production on Thu Feb 8 17:01:15 2024
Version 19.3.0.0.0
Copyright (c) 1982,
2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c
Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
q SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
q SQL> alter pluggable database ORCLPDB close;
Pluggable database altered.
q SQL> drop pluggable database ORCLPDB
including datafiles;