Clone PDB from Unplugged PDB


Overview

This procedure demonstrates cloning an unplugged PDB multiple times.

References

Procedure

This procedure is based on “ 38.5.2 Plugging In an Unplugged PDB ”.

Set Database Environment

Set the database environment to the JAM instance as follows:

. oraenv

The expected output is:

ORACLE_SID = [ocm12c] ? jar
The Oracle base remains unchanged with value /opt/app/oracle

Start SQL*Plus Session

Start a SQL*Plus session as follows:

sqlplus / as sysdba

The expected output is:

SQL*Plus: Release 12.1.0.2.0 Production on Wed Oct 23 13:36:21 2019

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

Connected to an idle instance.

Startup JAM Instance

Run the following SQL command to start the JAM instance:

startup

The expected output is:

ORACLE instance started.

Total System Global Area 1543503872 bytes
Fixed Size                  2924736 bytes
Variable Size             939528000 bytes
Database Buffers          587202560 bytes
Redo Buffers               13848576 bytes
Database mounted.
Database opened.

See Current State of PDBs

Run the following SQL query to what the state of all the PDBs are:

select name, open_mode from V$PDBS;

The expected output is:

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PLUM                           READ WRITE
JAM                            READ WRITE
VEGEMITE                       READ ONLY
VEGEMITER                      READ WRITE

See “ Create Snapshot Copy Clone ” for an explanation of the status of the last two (2) PDBs.

Attempt to Unplug JAM PDB

Run the following SQL command to unplug the JAM PDB:

alter pluggable database jam unplug into 'jam.xml';

The command failed with the following errors:

alter pluggable database jam unplug into 'jam.xml'
*
ERROR at line 1:
ORA-65025: Pluggable database JAM is not closed on all instances.

I forgot to close the PDB before unplugging.

Close JAM PDB

Run the following SQL command to close the JAM PDB:

alter pluggable database jam close;

The expected output is:

Pluggable database altered.

Unplug JAM PDB

Run the following SQL command to unplug the JAM PDB:

alter pluggable database jam unplug into 'jam.xml';

The expected output is:

Pluggable database altered.

Attempt to Plug JAM PDB back In

Run the following SQL command to plug the JAM PDB back in as a clone:

create pluggable database jam as clone using 'jam.xml';

The command failed with the following errors:

create pluggable database jam as clone using 'jam.xml'
*
ERROR at line 1:
ORA-65012: Pluggable database JAM already exists.

Even though the PDB has been unplugged, it is still registered to the root container.

Drop JAM PDB

Run the following SQL command to drop the JAM PDB:

drop pluggable database jam;

The expected output is:

Pluggable database dropped.

See Current State of PDBs

Run the following SQL query to what the state of all the PDBs are:

select name, open_mode from V$PDBSs

The expected output is:

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PLUM                           READ WRITE
VEGEMITE                       READ ONLY
VEGEMITER                      READ WRITE

The JAM PDB seems to have been removed.

Confirm JAM PDB Has Been Removed

Run the following SQL query to confirm JAM PDB has been removed:

select pdb_name,status from DBA_PDBS;

The expected output is:

PDB_NAME  STATUS
--------- ------
PDB$SEED  NORMAL
PLUM      NORMAL
VEGEMITE  NORMAL
VEGEMITER NORMAL

Clone Unplugged JAM PDB as JAM0

Run the following SQL command to plug the unplugged JAM PDB back in as clone called JAM0:

create pluggable database jam0 as clone using 'jam.xml';

The expected output is:

Pluggable database created.

Clone Unplugged JAM PDB as JAM1

Run the following SQL command to plug the unplugged JAM PDB back in as clone called JAM1:

create pluggable database jam1 as clone using 'jam.xml'

The expected output is:

Pluggable database created.

Opem Cloned PDBs As Read/Write

Run the following SQL command to opem cloned PDBs as read/write:

alter pluggable database jam0, jam1 open;

The expected output is:

Pluggable database altered.

See Current State of PDBs

Run the following SQL query to what the state of all the PDBs are:

select name, open_mode from V$PDBS;

The expected output is:

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PLUM                           READ WRITE
JAM0                           READ WRITE
VEGEMITE                       READ ONLY
VEGEMITER                      READ WRITE
JAM1                           READ WRITE

6 rows selected.

Save Current State of Cloned PDBs

Run the following SQL command to save the current open mode of these new PDBs (JAM0 and JAM1):

alter pluggable database jam0, jam1 save state;

The expected output is:

Pluggable database altered.