Showing posts with label database 12c. Show all posts
Showing posts with label database 12c. Show all posts

Saturday, March 29, 2014

Starting a Pluggable database in 12c

In Oracle 12c when we open a CDB (Container database), the PDBs(Pluggable Databases in the CDB) are by default in mount mode.

Solution: We either need to open the pluggable databases manually or we can create a trigger which can bring up the pluggable databases once the CDB is started.

If we want the PDBs to be opened manually issue the below command in the CDB:
alter pluggable database <pdb_name> open;

If we want the PDBs to be opened automatically, we can create a database event trigger that opens all the PDBs after STARTUP.

Create the below trigger in the CDB, which will bring up all the pluggable database when the CDB instance starts 

CREATE TRIGGER OPEN_ALL_PDBs
after startup on database
begin
execute immediate 'alter pluggable database all open';
end Open_ALL_PDBs;
/

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.
  



Thursday, August 15, 2013

Oracle 12c Pluggable Database Creation Method 1: using command line

How to Create Oracle Pluggable database
Method 1: Create new PDB from PDB$SEED pluggable database using command line.

Environment Details:
OS: Sun Solaris 5.10
Database Version: 12C
User: oracle
CDB Database Name: CDB1
Root Database Name: CDB$ROOT
Seed Database Name: PDB$SEED (Template database, always in READ ONLY Mode)
PDB Database Name: PDB1


1. Connect to the root database with the user having "CREATE PLUGGABLE DATABASE" system privilege. In this case we have used SYS user.


2. Issue the below to create the pluggable database in the container database.
CREATE PLUGGABLE DATABASE pdb1
ADMIN USER pdbadmin IDENTIFIED BY pdbadmin1 ROLES=(CONNECT)
FILE_NAME_CONVERT =  ('/u01/oradata/ora12c/pdbseed','/u01/oradata/ora12c/pdb1');


3. When the pluggable database is created it is in MOUNTED Mode, we need to OPEN the database to use it.
ALTER PLUGGABLE DATABASE pdb1 OPEN;