Quick & Dirty: Create a pluggable database in Oracle 12c
- Log in as sys
- Change to CDB$ROOT and verify container:
SQL> alter session set container = cdb$root; Session altered. SQL> show con_name CON_NAME ------------------------------ CDB$ROOT
- Create plugable database from seed (this command also adds the new pdb2 directory):
create pluggable database pdb2 admin user pdb2_admin identified by secret_password file_name_convert =( '/home/oracle/app/oracle/oradata/cdb1/pdbseed/', '/home/oracle/app/oracle/oradata/cdb1/pdb2/' );
- At this point the database is created and mounted. Open new database:
SQL> alter pluggable database pdb2 open read write;
- List pluggable databases:
alter session set container=CDB$ROOT; col pdb_name for a30 col status for a10 col status for a10 select a.pdb_name,a.status,b.open_mode from dba_pdbs a, v$pdbs b where a.pdb_name = b.name(+) order by 1 / PDB_NAME STATUS OPEN_MODE ------------------------------ ---------- ---------- ORCL NORMAL READ WRITE PDB$SEED NORMAL READ ONLY PDB2 NORMAL READ WRITE
- Create a new tnsnames.ora entry for the database:
PDB2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb2) ) )
- Log in as pdb2_admin:
sqlplus pdb2_admin/secret_password@pdb2
- Log in as sys to pdb2:
-
sqlplus sys@pdb2 as sysdba;
or
-
sqlplus sys as sysdba; alter session set container = pdb2;
-
The new database will have three tablespaces;
SQL> select tablespace_name,contents from dba_tablespaces;
TABLESPACE_NAME CONTENTS ------------------------------ --------- SYSTEM PERMANENT SYSAUX PERMANENT TEMP TEMPORARY
For more information see the Oracle-Base article.