Sunday, December 8, 2013

Oracle Database 12c–Create PDB from PDBSEED example

[oracle@gc12c ~]$ sqlplus sys/password@cdborcl as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Sun Dec 8 22:04:50 2013

Copyright (c) 1982, 2013, 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/cdborcl/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/cdborcl/pdbseed','/u01/app/oracle/oradata/cdborcl/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
cdborcl 1
cdborclXDB 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/cdborcl/pdb1/system01.dbf
/u01/app/oracle/oradata/cdborcl/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/cdborcl/undotbs01.dbf
/u01/app/oracle/oradata/cdborcl/pdb1/system01.dbf
/u01/app/oracle/oradata/cdborcl/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/cdborcl/sysaux01.dbf
1 /u01/app/oracle/oradata/cdborcl/system01.dbf
1 /u01/app/oracle/oradata/cdborcl/undotbs01.dbf
1 /u01/app/oracle/oradata/cdborcl/users01.dbf
2 /u01/app/oracle/oradata/cdborcl/pdbseed/sysaux01.dbf
2 /u01/app/oracle/oradata/cdborcl/pdbseed/system01.dbf
3 /u01/app/oracle/oradata/cdborcl/demo/SAMPLE_SCHEMA_users01.dbf
3 /u01/app/oracle/oradata/cdborcl/demo/example01.dbf
3 /u01/app/oracle/oradata/cdborcl/demo/sysaux01.dbf
3 /u01/app/oracle/oradata/cdborcl/demo/system01.dbf
4 /u01/app/oracle/oradata/cdborcl/pdb1/sysaux01.dbf
4 /u01/app/oracle/oradata/cdborcl/pdb1/system01.dbf

12 rows selected.


SQL> alter session set container=cdb$root;

Session altered.

SQL> conn pdb1_admin/password@gc12c: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@cdborcl as sysdba
Connected.


SQL> alter pluggable database pdb1 close immediate;

Pluggable database altered.

SQL> conn pdb1_admin/password@gc12c:1521/pdb1
ERROR:
ORA-01033: ORACLE initialization or shutdown in progress
Process ID: 0
Session ID: 0 Serial number: 0

No comments:

Post a Comment