Cloning of PDB database into same CDB database Oracle

Cloning of PDB database into same CDB database in Oracle 12c

Step 1: Create new directory in oradata folder e.g PDB2 (location where you want to create database).

Step 2: Connect to container database( CDB)
sqlplus sys as sysdba

Step 3: Check the pluggable database status

SQL> select name,open_mode from v$pdbs;
NAME OPEN_MODE
-------- -----------
PDB$SEED READ ONLY
PDB1 READ WRITE

Step 4: Close the pdb1 database

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

step 5: Open in read only mode PDB1 database.

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

Step 6: Start cloning process from pdb1 to pdb2.

Option 1:It will create files as oracle managed file system otherwise you need to specify manually each file.

SQL> create pluggable database pdb2 from pdb1 create_file_dest='D:\container\oradata\cdb1\pdb2';

Option 2: It will create the exact struture as present in old pdb.

SQL> CREATE PLUGGABLE DATABASE pdb3 FROM pdb1
FILE_NAME_CONVERT = ('D:\container\oradata\cdb1\pdb1\', 'D:\container\oradata\cdb1\pdb3\')
PATH_PREFIX = 'D:\container\oradata\cdb1\pdb3';
Pluggable database created.

Step 7: Check the database

SQL> select name,open_mode from v$pdbs;

NAME      OPEN_MODE
--------  -----------
PDB$SEED  READ ONLY
PDB1      READ ONLY
PDB2      MOUNTED

Step 8: Open the database for user

alter pluggable database pdb1 close;
alter pluggable database pdb1 open;

alter pluggable database pdb2 close;
alter pluggable database pdb2 open;

Step 9: check file location and status

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;

select con_id, tablespace_name, File_Name from cdb_data_files order by 1, 2;

Step 10: Drop the PDB database

-- It will keep datafiles on disk only temp tablespace is deleted
DROP PLUGGABLE DATABASE pdb1 KEEP DATAFILES;

-- It will drop all the datafiles associated with pluggable database
DROP PLUGGABLE DATABASE pdb1 INCLUDING DATAFILES;

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 )

w

Connecting to %s