References
Creating a PDB
There are several ways of creating a PDB:
- Create a PDB from the SEED PDB
- From an existing PDB
- Create a PDB from an existing non-CDB Database
- Plug a PDB from one CDB into another
See also the OCM12C topic, Create and manage pluggable databases
Create a PDB from the SEED PDB
Run the following commands:
ALTER SESSION SET container = cdb$root;
CREATE PLUGGABLE DATABASE plum ADMIN USER plummer IDENTIFIED BY "Christopher";
ALTER PLUGGABLE DATABASE plum OPEN READ WRITE;
CONNECT plummer/Christopher@localhost/plum.yaocm.id.au
Create a PDB from an existing PDB
In the JAR CDB, I ran the following commands to create VEGEMITE from JAM:
ALTER SESSION SET container = cdb$root;
ALTER PLUGGABLE DATABASE jam CLOSE;
ALTER PLUGGABLE DATABASE jam OPEN READ ONLY;
CREATE PLUGGABLE DATABASE vegemite FROM jam;
ALTER PLUGGABLE DATABASE vegemite OPEN;
Note: No need for file name conversion because I am using OMF in JAR.
Create a PDB from an existing non-CDB Database
I created a database using the procedure in Create 12C Non-CDB Database Using OMF .
After connecting to CAN , I ran the following command:
exec dbms_pdb.describe('can_db.xml')
After connecting to JAR , I ran the following PL/SQL block to verify that the export information in 'can_db.xml' was usable to create a PDB called BISCUIT in the JAR CDB:
SET SERVEROUTPUT ON SIZE UNLIMITED
BEGIN
IF dbms_pdb.check_plug_compatibility('can_db.xml', 'biscuit') THEN
dbms_output.put_line('Pluggable');
ELSE
dbms_output.put_line('Not pluggable');
END IF;
END;
/
The result was:
Pluggable
The BISCUIT PDB is created from CAN as follows:
CREATE PLUGGABLE DATABASE biscuit USING 'can_db.xml';
Then, the following script is used to do the conversion from non-CDB to PDB:
ALTER SESSION SET CONTAINER=biscuit;
@?/rdbms/admin/noncdb_to_pdb
Plug a PDB from one CDB into another
Close the VEGEMITE PDB, unplug it, and drop it as follows:
ALTER SESSION SET container=cdb$root;
ALTER PLUGGABLE DATABASE vegemite CLOSE;
ALTER PLUGGABLE DATABASE vegemite UNPLUG INTO 'vegemite.xml';
DROP PLUGGABLE DATABASE vegemite;
Check the validity of the XML file as follows:
SET SERVEROUTPUT ON SIZE UNLIMITED
BEGIN
IF dbms_pdb.check_plug_compatibility('vegemite.xml', 'VEGEMITE') THEN
dbms_output.put_line('Pluggable');
ELSE
dbms_output.put_line('Not pluggable');
END IF;
END;
/
Plug the PDB back in, and open it as follows (NOCOPY is used because the data files are unchanged):
CREATE PLUGGABLE DATABASE vegemite USING 'vegemite.xml' NOCOPY;
ALTER PLUGGABLE DATABASE vegemite OPEN READ WRITE;