Monday , December 23 2024

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.

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *