In Oracle 12c multitenant databases CDBs are containers databases which hold oracle internals, supplied accounts and processes and client PDBs pluggable databases for applications. Connections to CDBs can be from the OS layer by supplying the SID via environmental variables or directly and through oracle networking. This procedure demonstrates the connection through both processes.
Connection via OS layer
- Connect to your oracle database server as the oracle software owner.
[larry@linux2 ~]$ su – oracle
Password:
Last login: Mon Jun 24 11:43:05 EDT 2016 on pts/1
[oracle@linux2 ~]$
- Verify that you have environment has the appropriate SID set with command echo $ORACLE_SID. If it is not the appropriate SID change which the export ORACLE_SID= statement.
[oracle@linux2 ~]$ echo $ORACLE_SID
cdb1
[oracle@linux2 ~]$ export ORACLE_SID=cdb1
[oracle@linux2 ~]$ echo $ORACLE_SID
cdb1
[oracle@linux2 ~]$
- Now you can connect directly into the CDB referenced by the environmental parameter ORACLE_SID with the command sqlplus / as sysdba. NOTE: You are connecting with the administrative account
[oracle@linux2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Mon Jun 24 12:26:00 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 – 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
- This completes connecting the CDB from OS layer
Connection via Oracle networking
- Connect to your oracle database server as the oracle software owner.
[larry@linux2 ~]$ su – oracle
Password:
Last login: Mon Jun 24 11:43:05 EDT 2016 on pts/1
[oracle@linux2 ~]$
- List the values in your local tnsnames.ora file to find the appropriate Alias for the CDB you which to connect to with the command: cat $ORACLE_HOME/network/admin/tnsnames.ora.
[oracle@linux2 ~]$ cat $ORACLE_HOME/network/admin/tnsnames.ora
CDB1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.30.15.75)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cdb1)
(SID = cdb1)
)
)
PDB1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.30.15.75)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb1)
(SID = cdb1)
)
)
[oracle@linux2 ~]$
- In this example, we want to connect to cdb1 referenced by CDB1. Supply the sqlplus connection string with the tag: @CDB1 to complete your connection as shown below.
[oracle@linux2 ~]$ sqlplus sys/password@CDB1 as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Mon Jun 24 12:41:24 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 – 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
- This completes connection to CDB via oracle networking.
Larry Catt
OCP