11 September 2015

step by step Clone a Pluggable Database (PDB) Manually

PDB Clones in Oracle Database 12c Release 1 (12.1.0.2)

[oracle@r12c ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.2.0 Production on Fri Sep 11 11:33:26 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL> select con_id, name, open_mode, total_size from v$pdbs;

    CON_ID NAME                           OPEN_MODE  TOTAL_SIZE
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY   838860800
         4 ORCL                           READ WRITE 2945187840

SQL> alter session set container=ORCL;

Session altered.

Creating the user for testing purpose.

SQL> create user muthu identified by muthu;

User created.

SQL> SELECT NAME,OPEN_MODE FROM V$PDBS;

NAME                           OPEN_MODE
------------------------------ ----------
ORCL                           READ WRITE

SQL> alter pluggable database ORCL close;

Pluggable database altered.

SQL> alter pluggable database ORCL open read only;

Pluggable database altered.

Cloning full database from ORCL to ORCLNEW.

SQL> CREATE PLUGGABLE DATABASE orclnew from orcl FILE_NAME_CONVERT = ('/db/app/product/oradata/orcl/pdb1','/db/app/product/oradata/orclnew/');

Pluggable database created.

SQL> alter pluggable database orclnew open read write;

Pluggable database altered.

SQL> alter pluggable database orcl close;

Pluggable database altered.

SQL> alter pluggable database orcl open read write;

Pluggable database altered.

SQL> SELECT NAME,OPEN_MODE FROM V$PDBS;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
ORCLNEW                        READ WRITE
ORCL                           READ WRITE

Checking the contents of the muthu user in the new PDB show the user is present,

SQL> alter session set container=ORCLNEW;

Session altered.
SQL> col USERNAME format a20
SQL> select USERNAME,CREATED from DBA_users where USERNAME='MUTHU';

USERNAME             CREATED
-------------------- ---------
MUTHU                11-SEP-15

SQL> show con_name;

CON_NAME
------------------------------
ORCLNEW
SQL> alter session set container=ORCL;

Session altered.

SQL> select USERNAME,CREATED from DBA_users where USERNAME='MUTHU';

USERNAME             CREATED
-------------------- ---------
MUTHU                11-SEP-15

SQL> show con_name;

CON_NAME
------------------------------
ORCL
SQL>

No comments: