How to connect to Pluggable Databases in Oracle 19: A Step-by-Step Guide

Introduction

In this tutorial, I used the Default Service for connecting to the PDB. Made in the tnsnames.ora file that defines database addresses that allow us to establish a connection with the database. The status of the PDB needs to be changed from mounted to read-write mode.

The concept Databases in Oracle 19

  • The Container Database (CDB).
  • Pluggable Database (PDB).

Connect to Pluggable Databases in Oracle 19

  • Where cpdb is the global database.
  • pdb1 and pdb2 are the two pluggable databases created.

Made in the tnsnames.ora file as below:

$ sudo su - oracle
$ cat $ORACLE_HOME/network/admin/tnsnames.ora

#The content tnsnames.ora as below:

CPDB01 =
  (DESCRIPTION =
    (ENABLE = BROKEN)
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.x.x)(PORT = 1655))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = DEVOPSROLES)
      (SERVER = DEDICATED)
    )
  )

PDB01 =
  (DESCRIPTION =
    (ENABLE = BROKEN)
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.x.x)(PORT = 1655))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PDB01_DEVOPSROLES)
      (SERVER = DEDICATED)
    )
  )

PDB02 =
  (DESCRIPTION =
    (ENABLE = BROKEN)
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.x.x)(PORT = 1655))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PDB02_DEVOPSROLES)
      (SERVER = DEDICATED)
    )
  )

Changing the status of the pluggable database

When the pdbs are created, by default, the open_mode is ‘Mounted’ only. Query status opens mode pdbs as command below:

$ sudo su - oracle
$ export ORACLE_SID=CPDB01
$ sqlplus "/as sysdba"
SQL> select name, open_mode from v$pdbs;

If pdbs open mode is “Mounted” only. You run the command that opens all the pluggable databases in a read-write mode.

SQL> Alter pluggable database all open;

After this connection can be established with the database using sqlplus command as below:

$ sqlplus "sys/oracle@PDB01"
How to connect to Pluggable Databases in Oracle 19

Conclusion

Thought the article, “How to connect to Pluggable Databases in Oracle 19″ as above. Connecting to pluggable databases in Oracle 19c is a fundamental skill for anyone working with Oracle’s advanced database management system. By following the steps outlined in this guide, you can easily manage and connect to your PDBs, taking full advantage of Oracle’s multi-tenant architecture.

This capability not only simplifies database administration but also enhances scalability and resource management. Stay proactive in exploring and mastering Oracle’s features to keep your database environment efficient and cutting-edge. I hope will this your helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.