iSelfSchooling.com  Since 1999     References  |  Search more  | Oracle Syntax  | Free Online Oracle Training

    Home      .Services     Login       Start Learning     Certification      .                 .Share your BELIEF(s)...

 

. Online Accounting        .Copyright & User Agreement   |
    .Vision      .Biography     .Acknowledgement

.Contact Us      .Comments/Suggestions       Email2aFriend    |

 

Oracle 12c New Features

Online Oracle Training

LESSON 08

How to clone a pluggable database

 

In this lesson, you will create a new pluggable database (mypdb2_clone) from mypdb2.

Assuming you have already connected to root.

 

Before you perform cloning, you should make directory for your cloning database.

# cd /oradata/mycdb

# mkdir mypdb2_clone

# cd mypdb2_clone

# pwd

/oradata/mycdb/mypdb2_clone

 

Connect to the root and clone mypdb2_clonefrom mypdb2.

SQL> connect / as sysdba

 

Close the mypdb2 pluggable database and open it to READ ONLY before cloning.

SQL> ALTER PLUGGABLE DATABASE mypdb2 CLOSE;

 

Open the mypdb2 PDB to read only.

SQL> ALTER PLUGGABLE DATABASE mypdb2 OPEN READ ONLY;

 

Change OMF DB_CREATE_FILE_DEST parameter value.

SQL> ALTER SYSTEM SET db_create_file_dest="/oradata/mycdb/mypdb2_clone";

 

Now, you can clone the mypdb2_clone pluggable database from mypdb2.

SQL> CREATE PLUGGABLE DATABASE mypdb2_clone FROM mypdb2;

 

Now, check to see that the mode of mypdb2_clone is open. Query the V$PDBS view.

SQL> SELECT con_id, name, open_mode, dbid FROM v$pdbs;

 

CON_ID

NAME

OPEN_MODE

DBID

2

PDB$SEED

READ ONLY

3654327692

3

MYPDB1

READ WRITE

6783241652

4

MYPDB2

READ ONLY

7549320153

5

MYPDB2_CLONE

MOUNTED

8734290212

Notice that the open_mode value for the mypdb2_clone pluggable database is "MOUNTED" and "READ ONLY" for the mypdb2 PDB.

 

Change the mypdb2 open mode from read only to read write. First you need to close the database and then open it.

 

Close the mypdb2 database.

SQL> ALTER PLUGGABLE DATABASE mypdb2 CLOSE;

 

Change the mypdb2 pluggable database open mode to READ WRITE.

SQL> ALTER PLUGGABLE DATABASE mypdb2 OPEN;

 

Change the mypdb2_clone pluggable database from mount to READ WRITE.

SQL> ALTER PLUGGABLE DATABASE mypdb2_clone OPEN;

 

Now, check to see that the mode of all the pluggable databases. Query the V$PDBS view.

SQL> SELECT con_id, name, open_mode, dbid FROM v$pdbs;

 

CON_ID

NAME

OPEN_MODE

DBID

2

PDB$SEED

READ ONLY

3654327692

3

MYPDB1

READ WRITE

6783241652

4

MYPDB2

READ WRITE

7549320153

5

MYPDB2_CLONE

READ WRITE

8734290212

 

Use the netca tool to create a net service name for the mypdb2_clone pluggable database and name it mypdb2_clone

 

Login to the mypdb2_clone PDB as sysdba

# sqlplus /nolog

SQL> connect sys/mypass@mypdb2_clone as sysdba

 

You can use EasyConnect to the mypdb2_clone pluggable database as sysdba.

SQL> connect sys/mypass@localhost:1521/mypdb2_clone as sysdba

 

To drop a pluggable database, you need to close the database and then drop the pluggable database with the including datafiles option.

SQL> ALTER PLUGGABLE DATABASE mypdb2_clone CLOSE IMMEDIATE;

SQL> DROP PLUGGABLE DATABASE mypdb2_clone INCLUDING DATAFILES;

 

Good Luck!

 

 

Google
 
Web web site