Friday, August 16, 2013

Oracle 12c Pluggable Database Creation Method 2: from Non CDB to CDB

How to Create Oracle Pluggable database
Method 2: Create new PDB from by plugging non-CDB into CDB. We are using DBMS_PDB package in this post, which is applicable only to the databases created in 12C and higher versions.

Environment Details:
OS: Sun Solaris 5.10
Database Version: 12C
CDB Database Name: CDB12C
Root Database Name: CDB$ROOT
Source Database Name: ORCLDB
PDB Database Name: PDB2
User: oracle

1. Connect to the Non-CDB database and shut it down, then open it in READ ONLY Mode.



2. Execute the below procedure which will generate a xml file that will be used to create the new PDB Database.
EXEC DBMS_PDB.DESCRIBE ('/u01/app/oracle/pdb2.xml');


3. Connect to target CDB database with a user having "CREATE PLUGGABLE DATABASE" privilege.


4. Set the PDB_FILE_NAME_CONVERT parameter to the new location where the datafiles for the pdb database will be created. 


5. Use the function DBMS_PDB.CHECK_PLUG_COMPATIBILITY to check the compatibility and  query the pdb_lug_in_violations view to view the violations. If there is any major issues, proceed accordingly

BEGIN
  IF DBMS_PDB.CHECK_PLUG_COMPATIBILITY('/u01/app/oracle/pdb2.xml','pdb2') THEN
    dbms_output.put_line('TRUE');
  ELSE
    dbms_output.put_line('FALSE');
  END IF;
END;
/

SELECT MESSAGE, ACTION FROM PDB_PLUG_IN_VIOLATIONS;


6. Plug in the database orcldb as pluggable database pdb2, Once the database is created, it will be in MOUNTED Mode.
   CREATE PLUGGABLE DATABASE pdb2 USING '/u01/app/oracle/pdb2.xml';


7. Create a service using netca for the new database(pdb2) and connect to it as sys user using this service. Run the noncdb_to_pdb.sql script before opening the pdb database. This script will delete all the unnecessary metadata from the system tablespace of the newly created PDB database.


8. Finally OPEN the pluggable database.
  



No comments:

Post a Comment