Clone a PDB within the same 12c CDB

Clone a PDB within the same 12c CDB

set DB_CREATE_FILE_DEST= ‘clonepdb’ (OMF)

SQL> SELECT * FROM cdb_pdbs;

PDB_ID PDB_NAME DBID CON_UID GUID STATUS CREATION_SCN VSN LOGGING FOR FOR CON_ID
———- ———- ———- ———- ——————————– ——— ———— ———- ——— — — ———-
3 TESTB 2450946039 2450946039 24AA8B6BE6892EF3E053DF80090A6494 NORMAL 1788902 202375680 LOGGING NO NO 3
2 PDB$SEED 3865116345 3865116345 24A9CFCD92376A00E053DF80090A37E1 NORMAL 1594427 202375680 LOGGING NO NO 2

SQL> select INST_ID,CON_ID,NAME,OPEN_MODE from gv$pdbs;

INST_ID CON_ID NAME OPEN_MODE
———- ———- —————————— ———-
1 2 PDB$SEED READ ONLY
1 3 TESTB READ WRITE
2 2 PDB$SEED READ ONLY
2 3 TESTB READ WRITE
SQL> alter pluggable database TESTB close immediate instances=all;

Pluggable database altered.
SQL> alter pluggable database TESTB open read only instances=all;

Pluggable database altered.

SQL> select INST_ID,CON_ID,NAME,OPEN_MODE from gv$pdbs;

INST_ID CON_ID NAME OPEN_MODE
———- ———- —————————— ———-
1 2 PDB$SEED READ ONLY
1 3 TESTB READ ONLY
2 2 PDB$SEED READ ONLY
2 3 TESTB READ ONLY
SQL> create pluggable database CLONEPDB from TESTB;
srvctl add service -db TESTb_tp -s CLONEPDB_ANY -pdb CLONEPDB -preferred TESTbt1,TESTbt2

srvctl start service -db TESTb_tp -s CLONEPDB_ANY

SQL> alter pluggable database CLONEPDB open instances=all;

Pluggable database altered.

SQL> alter pluggable database TESTB close instances=all;

Pluggable database altered.

SQL> alter pluggable database TESTB open instances=all;

Pluggable database altered.

SQL> select INST_ID,CON_ID,NAME,OPEN_MODE from gv$pdbs;

INST_ID CON_ID NAME OPEN_MODE
———- ———- —————————— ———-
1 2 PDB$SEED READ ONLY
1 3 TESTB READ WRITE
1 4 CLONEPDB READ WRITE
2 2 PDB$SEED READ ONLY
2 3 TESTB READ WRITE
2 4 CLONEPDB READ WRITE

6 rows selected.

Cheers