Tuesday, October 7, 2014

Creation of CDB

The following blog explains how to create a CDB named cdbtest containing 1 PDB  named pbdtest
  • export ORACLE_SID=cdbtest
  • To be authenticated with a password file create a password file
  • Create the initialization parameter file
  • Connect to the instance
  • Create a server parameter file
  • Start the instance with nomount option
  • Issue the create database

The create database command has following additional clause to indicate that it is CDB

enable pluggable database
seed file_name_convert=('/u01/app/oracle/oradata/testcdb', '/u01/app/oracle/oradata/pdbseed')

Enable pluggable database clause creates a CDB with a root and a seed

The seed file_name_convert generates file names for the seed's file in /u01/app/oracle/oradata/pbdseed directoru using filenames in the /u01/app/oracle/oradata/testcdb directory.

After you create a CDB it consist of the root and the seed.

  • Create additional tablespaces if required
  • Run scripts to build data dictionary views

The following three scripts needs to be run:
catalog.sql
catproc.sql
pubbld.sql

  • Create PDBs to store user data,.
You can create a PDB from the seed using the create pluggable database statement.
create pluggable database testpdb admin user testpdb identified by test123 file_name_convert=('/test1/bench/pdbseed','/test1/bench/testpdb' );
  • PDB is now in mount state, modify its mode to OPEN
alter pluggable database testpdb open ;

  •  Set the current session to point to PDB
alter session set container=testpdb ;
  • Create a local user which will own the schema
create user test identified by test;
grant dba to test;
  • Clone a pbd from existing pdb.
A PDB namely testpdb exist. We need to clone this pbd and call the cloned PDB as clonePDB
Open source pdb in read-only mode
create pluggable database clonepdb from testpdb file_name_convert=('/testpbd,'clonepdb') ;
; change the mode to open


  • Is it a CDB or a non-CDB database
select cdb from V$database

  • What does the various con_id stand for:

con_id        desc
0                    the data pertains to entire PDB
1                     the data pertains to the root (oracle metadata)
2                    the data pertains to the seed
3                    the data pertains to the PDB


  • How many tablespace do I have after I create a CDB containing 1 PDB:

SQL> select name,con_id from v$tablespace;

NAME                               CON_ID
------------------------------ ----------
SYSTEM                                  1
SYSAUX                                  1
UNDOTBS1                                1
USERS                                   1
TEMP                                    1
SYSTEM                                  2
SYSAUX                                  2
TEMP                                    2
SYSTEM                                  3
SYSAUX                                  3
TEMP                                    3

NAME                               CON_ID
------------------------------ ----------
USERS                                   3


The root ,seed and PDB has system, sysaux and temp tablespace each.

Additionally , the root container has UNDO tablespace . Root and PDB conainters also has user tablespace.


  • What is my user and con_id and con_name

SQL> show user;
USER is "SYS"
SQL> show con_id;

CON_ID
------------------------------
1
SQL> show con_name

CON_NAME
------------------------------


  • How many PDBs are exist in a given CDB


cdb_pdbs or dba_pdbs
How many containers does it have:

No comments:

Post a Comment