DBA Hub

📋Steps in this guide1/6

CREATE NEW PDB BY CLONING AN EXISTING PDB - Bright DBA

Goal: CREATE NEW PLUGGABLE DATABASE (PDB2) BY CLONING AN EXISTING PLUGGABLE DATABASE (PDB1) Contents

oracle clusteringintermediate
by OracleDba
13 views
1

Overview

Goal: CREATE NEW PLUGGABLE DATABASE (PDB2) BY CLONING AN EXISTING PLUGGABLE DATABASE (PDB1) Contents 1. Pre-requisites
2

Section 2

1. Pre-requisites 2. Close existing PLUGGABLE DATABASE PDB1 3. Open existing PLUGGABLE DATABASE PDB1 in Read-Only

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
SQL>
select name,open_mode,con_id from v$database;
NAME                 OPEN_MODE                CON_ID
-------------------- -------------------- ----------
CDB2                 READ WRITE                    0

SQL>
show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL>
show pdbs;
CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
<---
SQL>
SQL> col name for a60
SQL>
select name from v$datafile where con_id=3;
NAME
------------------------------------------------------------
/home/oracle/oradata/PDB1system01.dbf
/home/oracle/oradata/PDB1sysaux01.dbf
/home/oracle/oradata/PDB1undotbs01.dbf
/home/oracle/oradata/PDB1/pdb1_users01.dbf

SQL>
select name from v$tempfile where con_id=3;
NAME
------------------------------------------------------------
/home/oracle/oradata/PDB1temp01.dbf

SQL>
alter pluggable database PDB1 close immediate;
Pluggable database altered.

SQL>
3

Section 3

3. Open existing PLUGGABLE DATABASE PDB1 in Read-Only 3 PDB1 READ ONLY NO <---- 4. Create new directory at OS level

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
SQL>
alter pluggable database PDB1 open read only;
Pluggable database altered.

SQL>
show pdbs;
CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ ONLY  NO  <----
SQL>

SQL>
!mkdir -p /home/oracle/oradata/PDB2
4

Section 4

5. CREATE NEW PDB (PDB2) BY CLONING AN EXISTING PDB (PDB1) <----- 6. OPEN NEW PLUGGABLE DATABASE PDB2

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
SQL>
CREATE PLUGGABLE DATABASE PDB2 FROM PDB1
FILE_NAME_CONVERT=('/home/oracle/oradata/PDB1','/home/oracle/oradata/PDB2/');
Pluggable database created.
<-----
SQL>
SQL>
show pdbs;
CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ ONLY  NO
4 PDB2                           MOUNTED  <-----
SQL>
5

Section 5

7. Close existing PLUGGABLE DATABASE PDB1 FROM RO MODE 8. Open existing PLUGGABLE DATABASE PDB1 in RW MODE

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
SQL>
alter pluggable database PDB2 open;
Pluggable database altered.

SQL>

SQL>
alter pluggable database PDB1 close immediate;
Pluggable database altered.

SQL>
6

Section 6

9. Verification Caution : Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

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>
alter pluggable database PDB1 open;
Pluggable database altered.

SQL>

SQL>
show pdbs;
CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
3 PDB1
READ WRITE
NO
4 PDB2                           READ WRITE NO  <----
SQL>
select name from v$datafile where con_id=4;
NAME
------------------------------------------------------------
/home/oracle/oradata/PDB2/system01.dbf
/home/oracle/oradata/PDB2/sysaux01.dbf
/home/oracle/oradata/PDB2/undotbs01.dbf
/home/oracle/oradata/PDB2/
pdb1_users01.dbf

SQL>
select name from v$tempfile where con_id=4;
NAME
------------------------------------------------------------
/home/oracle/oradata/PDB2/temp01.dbf

SQL>

Comments (0)

Please to add comments

No comments yet. Be the first to comment!