Site icon Database Tutorials

How To Connect to Container database (CDB) and Pluggable databases (PDB) in Oracle 12c

Connect to Root Container

The connection to the root container is the same as connecting to the database instance in previous versions. Connection can be established using OS authentication on the database server.

Find Service Names

We can find service names from the V$SERVICES view.

It is also possible to find service names with the lsnrctl tool.

Connect To Pluggable Database with Easy Connect Method

After specifying the service names, we can connect with the easy connect method as follows.

oradb.svcsubnetad3.svcvcn.oraclevcn.com -> hostname

pdb1.svcsubnetad3.svcvcn.oraclevcn.com   -> pdb1 pluggable database service name

Connect To Pluggable Database with Naming Method

We can connect with Naming method as follows. First we need to make sure that the TNS name exists in $ORACLE_HOME/network/admin/tnsnames.ora and that it is correct.

TNS information in the tnsnames.ora file:

Naming Method

Connect To Pluggable Database From Root Container

After connecting to the root container (CDB$ROOT), it is possible to switch to the corresponding pluggable databases via the alter session command or to the root container from pluggable databases.

Exit mobile version