DBA Hub

📋Steps in this guide1/3

How to clone a pluggable database for existing PDB - DBACLASS DBACLASS

We can clone a pluggable database from existing database easily. SQL> create pluggable database PROD_CL from PROD file_name_conver..

oracle clusteringintermediate
by OracleDba
13 views
1

Overview

In this article we will clone a pluggable database from existing PDB ( PROD), residing on the same container. First start the PDB in read only , which need to be cloned. Connect to the container and clone the pluggable:

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
SQL> select name,open_mode from v$pdbs;

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


SQL> alter session set container=PROD;

Session altered.

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/home/oracle/app/oracle/oradata/cdb1/prod/system01.dbf
/home/oracle/app/oracle/oradata/cdb1/prod/sysaux01.dbf

SQL> show con_name

CON_NAME
------------------------------
PROD


SQL> shutdown immediate;
Pluggable Database closed.

SQL> startup open read only
Pluggable Database opened.
2

Section 2

Now make the existing PDB ( PROD) from read only to read write: start the new cloned PDB( PROD_CL)

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
----If you don't connect to container , then below error will come

SQL>  create pluggable database PROD_CL from PROD FILE_NAME_CONVERT=('/home/oracle/app/oracle/oradata/cdb1/PROD','/home/oracle/app/oracle/oradata/cdb1/PROD_CL');
 create pluggable database PROD_CL from PROD FILE_NAME_CONVERT=('/home/oracle/app/oracle/oradata/cdb1/PROD','/home/oracle/app/oracle/oradata/cdb1/PROD_CL')
*
ERROR at line 1:
ORA-65040: operation not allowed from within a pluggable database


-- connect to container CDB1

SQL> conn sys/oracle@cdb1 as sysdba
Connected.
SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT



-- Clone pluggable 


SQL> create pluggable database PROD_CL from PROD FILE_NAME_CONVERT=('/home/oracle/app/oracle/oradata/cdb1/prod','/home/oracle/app/oracle/oradata/cdb1/PROD_CL');

Pluggable database created.

SQL> select name,open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
ORCL			       READ WRITE
PROD			       READ ONLY
PROD_CL 		       MOUNTED

SQL> alter session set CONTAINER=PROD;

Session altered.

SQL> shutdown immediate;
Pluggable Database closed.
SQL> startup
Pluggable Database opened.
SQL> show con_name
3

Section 3

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SQL> alter session set container=PROD_CL;

Session altered.

SQL> startup
Pluggable Database opened.


SQL> conn sys/oracle@cdb1 as sysdba
Connected.
SQL> select name,open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
ORCL			       READ WRITE
PROD			       READ WRITE
PROD_CL 		       READ WRITE

Comments (0)

Please to add comments

No comments yet. Be the first to comment!