To connect as sys or other elevated local users, use the same methods as below, but use ‘as sysdba‘ where necessary

Method 1:

alter session set container = pdbName;

Method 2:For other methods, you need to know the service-name for the PDB:
Get the service name for the PDB:

SELECT name || ' '|| pdb
FROM v$services
ORDER BY name;

or by doing “lsnrctl services LISTENER” and locating service for the PDB.

Method 2a: Using host and port without SCAN

connect user/pass@//host:port/pdbServiceName

or

sqlplus user/pass@//host:port/pdbServiceName

Method 2b: Using host and port with SCAN

Unix$> sqlplus localuser/password@//cluster-scan:scanPort/pdbServiceName
SQL> connect localuser/password@//cluster-scan:scanPort/pdbServiceName

Method 3: Using tns entry

Make Tns entry

  • with hostname and scan
  • with hostname and non-scan listener:

Without Scan:

PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdbServiceName)
)
)

With Scan:

PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan-name)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdbServiceName)
)
)

Then connect as follows:

“connect user/pass@PDB1”

or

“sqlplus user/pass@PDB1”

where PDB1 is the TNS alias

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Skant Gupta’s LinkedIn: www.linkedin.com/in/skantali/

Joel Perez’s LinkedIn: Joel Perez’s Profile

Anuradha’s LinkedIn: Anuradha’s Profile

LinkedIn Group: Oracle Cloud DBAAS

Facebook Page: OracleHelp

Leave a Reply

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