How to Clone Pluggable database within same Container Database

Clone Pluggable database within same Container Database


Cloning and Refresh are day-to-day activity which DBA perform on regular basic. In today blog , We will discuss about Cloning of the pluggable database with in the same Container database.

1) Run Below command to check and verify existing pluggable database:

SQL> set echo on
SQL> SET LINESIZE 200
SQL> SET PAGESIZE 10000
SQL> SET SERVEROUTPUT ON
SQL> COLUMN "DB DETAILS" FORMAT A100
SQL> SELECT 'DB_NAME: '||sys_context('userenv','db_name')||'/ CDB?:'||(select cdb from v$database)||'/ AUTH_ID:'
||sys_context('userenv','authenticated_identity')||'/ USER: '||sys_context('userenv','current_user')
||'/ CONTAINER:'||nvl(sys_Context('userenv','con_Name'),'NON-CDB') "DB DETAILS" FROM DUAL;


DB DETAILS
----------------------------------------------------------------------------------------------------
DB_NAME: cseeddb/ CDB?:YES/ AUTH_ID:oraware/ USER: SYS/ CONTAINER:CDB$ROOT

2) Run Below command to get information about pluggable database.

SQL> SET SERVEROUTPUT ON
SQL> COLUMN "RESTRICTED" FORMAT A10
SQL> select v.name, v.open_mode, nvl(v.restricted, 'n/a') "RESTRICTED", d.status
from v$PDBs v inner join dba_pdbs d
using (GUID) order by v.create_scn  ;

NAME                           OPEN_MODE  RESTRICTED STATUS
------------------------------ ---------- ---------- -------------
PDB$SEED                       READ ONLY  NO         NORMAL
PSEEDDB                        READ WRITE NO         NORMAL

3) Clone and open the pluggable database in READ ONLY mode.

SQL> alter pluggable database PSEEDDB close;
Pluggable database altered.
SQL> alter pluggable database PSEEDDB open read only;
Pluggable database altered.


4) Clone pluggable database using below command:
SQL> SET TIMING ON
SQL> create pluggable database clonedb
from PSEEDDB
file_name_convert = ('/pseeddb', '/clonedb') ;

5) Close and open both pluggable database.

SQL> alter pluggable database PSEEDDB close;
Pluggable database altered.

SQL> alter pluggable database PSEEDDB open;
Pluggable database altered.

SQL> alter pluggable database clonedb open;
Pluggable database altered.

6)Run Below command to get information about pluggable database.

SQL> SET SERVEROUTPUT ON
SQL> COLUMN "RESTRICTED" FORMAT A10
SQL> select v.name, v.open_mode, nvl(v.restricted, 'n/a') "RESTRICTED", d.status
from v$PDBs v inner join dba_pdbs d
using (GUID) order by v.create_scn  ;

NAME                           OPEN_MODE  RESTRICTED STATUS
------------------------------ ---------- ---------- -------------
PDB$SEED                       READ ONLY  NO         NORMAL
PSEEDDB                        READ WRITE NO         NORMAL

CLONEDB                        READ WRITE NO         NORMAL
7)Check and verify datafile for all container database.
select con_id, tablespace_name, File_Name
from cdb_data_files
order by 1, 2 ;





















Please read below books in order to know more about oracle CDB and PDB databases:
=============================================================


Comments

Popular posts from this blog

Data-At-Rest Encryption for Oracle database

Restore MySQL Database from mysqlbackup

Oracle 19c New Features