User Tools

Site Tools


12c_pluggable

Mangement

Create a pluggable database

CREATE PLUGGABLE DATABASE PDB01 ;

Startup pluggable database

ALTER PLUGGABLE DATABASE PDB01 OPEN ;

tnsnames.ora

Tnsnames is necessary for connecting to the pluggable databases with cli tools (sql*, expdp…)

vim  $ORACLE_HOME/network/admin/tnsnames.ora
PDB01 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PDB01)
    )
  )

Working with PDB's

List of Services (pdbs+cdbs)

SELECT NAME, CON_ID FROM V$ACTIVE_SERVICES ;

Info about currently connected instance

SET LINESIZE 200
SET PAGESIZE 10000
SET SERVEROUTPUT ON
COLUMN "DB DETAILS" FORMAT A100\
SELECT
 'DB_NAME: ' ||sys_context('userenv', 'db_name')||
 ' / CDB?: ' ||(SELECT cdb FROM v$database)||
 ' / AUTH_ID: ' ||sys_context('userenv', 'authenticated_identity')||
 ' / USER: ' ||sys_context('userenv', 'current_user')||
 ' / CONTAINER: '||nvl(sys_Context('userenv', 'con_Name'), 'NON-CDB')
 "DB DETAILS"
 FROM DUAL
 /

link

List PDBS from current container

COLUMN "RESTRICTED" FORMAT A10
SELECT 
   v.name, 
   v.open_mode, 
   nvl(v.restricted, 'n/a') "RESTRICTED", 
   d.status
FROM 
   v$pdbs     v 
INNER JOIN 
   dba_pdbs d
USING (GUID)
ORDER BY v.create_scn;

link

Connect from CDB

ALTER SESSION SET CONTAINER=PDB01 ;

With sql*

sqlplus 'sys/DBA@PDBTEST1 AS SYSDBA'
SELECT
     'DB_NAME: '  ||sys_context('userenv', 'db_name')||
  ' / CDB?: '     ||(SELECT cdb FROM v$database)||
  ' / AUTH_ID: '  ||sys_context('userenv', 'authenticated_identity')||
  ' / USER: '     ||sys_context('userenv', 'current_user')||
  ' / CONTAINER: '||nvl(sys_Context('userenv', 'con_Name'), 'NON-CDB')
   "DB DETAILS"
FROM DUAL
/
 
 
COLUMN "RESTRICTED" FORMAT A10 
SELECT v.name, v.open_mode, nvl(v.restricted, 'n/a') "RESTRICTED", d.status
FROM v$PDBs v INNER JOIN dba_pdbs d
USING (GUID)
ORDER BY v.create_scn
/
 
 

External doc

12c_pluggable.txt · Last modified: 2014/08/28 17:53 by dodger