Visit Counter

Sunday, November 17, 2013

Connecting to Container Databases (CDB) and Pluggable Databases (PDB) in Oracle Database 12c R.1


Connecting to Container Databases (CDB) and Pluggable Databases (PDB)

$ export ORACLE_SID=cdb1
$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Sat 17 15:20:10 2013
Copyright (c) 1982, 2013, Oracle. All rigths reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
with the partitioning, OLAP, Advance Analytics and real Application Testing options
SQL>


Switching Between Containers:



SQL> ALTER SESSION SET CONTAINER = pdb1;
session altered.
SQL> SHOW con_name

CON_NAME
---------------------------------
PDB1


SQL> ALTER SESSION SET container = cdb$root;
Session Altered.


SQL> SHOW CON_NAME

CON_NAME
-----------------------------
CDB$ROOT



Connecting to a Pluggable Database (PDB):


SQL> conn sys/xyz55555@localhost:1521/pdb1 as sysdba
Connected.


SQL> show con_name

CON_NAME
------------------------------
PDB1


Displaying the Current Container:


The SHOW CON_NAME command in SQL*Plus displays the current container name.


SQL> show con_name

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

CDB$ROOT


retrieved using the SYS_CONTEXT function.

SQL> SELECT SYS_CONTEXT('USERENV','CON_NAME')
FROM DUAL;



SYS_CONTEXT('USERENV','CON_NAME')
-----------------------------------------------------------------------

CDB$ROOT





No comments:

Post a Comment