Create PDB with Oracle Database 12c


[oracle@anar12c ~]$ sqlplus sys/password@cdbanardb as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Sun Dec 8 22:04:50 2014
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> ! mkdir /u01/app/oracle/oradata/cdbanardb/pdb1
SQL> create pluggable database pdb1
 2 admin user pdb1_admin identified by password
 3 roles = (DBA)
 4 file_name_convert=('/u01/app/oracle/oradata/cdbanardb/pdbseed','/u01/app/oracle/oradata/cdbanardb/pdb1');
Pluggable database created.
SQL> col pdb_name for a20
SQL> select pdb_name, status from cdb_pdbs;
PDB_NAME STATUS
-------------------- -------------
DEMO NORMAL
PDB$SEED NORMAL
PDB1 NEW
SQL> select name, open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
DEMO READ WRITE
PDB1 MOUNTED
SQL> select name, con_id from v$active_services order by 1;
NAME CON_ID
---------------------------------------------------------------- ----------
SYS$BACKGROUND 1
SYS$USERS 1
cdbanardb 1
cdbanardbXDB 1
demo 3
pdb1 4
6 rows selected.
SQL> alter pluggable database pdb1 open;
Pluggable database altered.
SQL> select pdb_name, status from cdb_pdbs;
PDB_NAME STATUS
-------------------- -------------
DEMO NORMAL
PDB$SEED NORMAL
PDB1 NORMAL
SQL> select name,open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
DEMO READ WRITE
PDB1 READ WRITE
SQL> select name from v$datafile where con_id=4;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/cdbanardb/pdb1/system01.dbf
/u01/app/oracle/oradata/cdbanardb/pdb1/sysaux01.dbf
SQL> alter session set container=pdb1;
Session altered.
SQL> show con_id
CON_ID
------------------------------
4
SQL> show con_name
CON_NAME
------------------------------
PDB1
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/cdbanardb/undotbs01.dbf
/u01/app/oracle/oradata/cdbanardb/pdb1/system01.dbf
/u01/app/oracle/oradata/cdbanardb/pdb1/sysaux01.dbf
 
SQL> select con_id,file_name from cdb_data_files order by 1,2;
CON_ID FILE_NAME
------ ----------------------------------------------------------------------
 1 /u01/app/oracle/oradata/cdbanardb/sysaux01.dbf
 1 /u01/app/oracle/oradata/cdbanardb/system01.dbf
 1 /u01/app/oracle/oradata/cdbanardb/undotbs01.dbf
 1 /u01/app/oracle/oradata/cdbanardb/users01.dbf
 2 /u01/app/oracle/oradata/cdbanardb/pdbseed/sysaux01.dbf
 2 /u01/app/oracle/oradata/cdbanardb/pdbseed/system01.dbf
 3 /u01/app/oracle/oradata/cdbanardb/demo/SAMPLE_SCHEMA_users01.dbf
 3 /u01/app/oracle/oradata/cdbanardb/demo/example01.dbf
 3 /u01/app/oracle/oradata/cdbanardb/demo/sysaux01.dbf
 3 /u01/app/oracle/oradata/cdbanardb/demo/system01.dbf
 4 /u01/app/oracle/oradata/cdbanardb/pdb1/sysaux01.dbf
 4 /u01/app/oracle/oradata/cdbanardb/pdb1/system01.dbf
12 rows selected.
SQL> alter session set container=cdb$root;
Session altered.
SQL> conn pdb1_admin/password@anar12c:1521/pdb1
Connected.
SQL> select name,open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------ ----------
PDB1 READ WRITE
SQL> select granted_role from dba_role_privs where grantee='PDB1_ADMIN';
GRANTED_ROLE
--------------------------------------------------------------------------------
PDB_DBA
SQL> conn sys/password@cdbanardb as sysdba
Connected.
SQL> alter pluggable database pdb1 close immediate;
Pluggable database altered.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: