Saturday, March 16, 2019

How to Create, Connect and Drop Pluggable database(PDB)


Some conceptual points for Create PLUGGABLE database -
  • Oracle 12c uses SEED$PDB as template to create new PDB's.
  • When you create a new PDB from SEED$PDB, you have to define admin user for that new PDB. This creates a local user inside the PDB.
  • Admin command also grants the PDB_DBA role to the ADMIN user that we created.
  • By default "CREATE PLUGGABLE DATABASE" command does not grant any privileges to the PDB_DBA role itself. So our admin user is powerless.
  • In order to let this user to control PDB, we have to explicitly grant dba role to PDB user.



Following is the command used to create new pluggable database in Oracle 12c.
> CREATE PLUGGABLE DATABASE my_new_pdb
   ADMIN USER my_pdb_admin IDENTIFIED BY password
   ROLES = (dba)
   DEFAULT TABLESPACE my_tbs 
   DATAFILE '/mnt/san_storage/oradata/orcl12c/my_new_pdb/mytbs01.dbf' SIZE 50M AUTOEXTEND ON
   FILE_NAME_CONVERT=('/oradata/orcl12c/pdbseed/','/oradata/orcl12c/my_new_pdb/');










To Check if this PDB is created run the following command
> select con_id, name from v$pdbs;









To connect the PDB, run following commands -
> alter pluggable database my_new_pdb open;
> exit;

sqlplus my_pdb_admin/password@localhost:1523/my_new_pdb
> show con_name;
> show con_id;
























Or, You can also use "alter session" command to directly connect to any container
> alter session set container = my_new_pdb;
> alter session set container = cbd$root;


To drop PDB use the following commands
> alter pluggable database my_new_pdb close;
> drop pluggable database my_new_pdb including datafiles;


















No comments:

Post a Comment

Oracle Database Administrator