You are on page 1of 6

11/14/22, 9:07 AM Connect to PDB as SYSDBA by ORACLE_PDB_SID - Ed Chen Logic

Ed Chen Logic
To Make My Logic More Logical

Authentication Multitenant

Connect to PDB as SYSDBA by ORACLE_PDB_SID


by Ed Chen / December 23, 2020

Ad removed.
Details

Connect as SYSDBA
We usually connect to the database by / as SYSDBA without providing any password for
maintenance works, such as startup, shutdown and backup. This is because we are in OSDBA or
OSOPER group, so we are naturally authenticated at OS-level and don't have to provide password
to login.

Connect to a PDB
In multitenant environments, the thing becomes a little different, we can still connect to Container
Database (CDB) without password by the traditional way, but not Pluggable Database (PDB).

If we want to connect to a PDB, we usually provide a connection string which includes credentials
and a tnsname to login.

[oracle@test ~]$ sqlplus sys/password@orclpdb as sysdba

...

SQL> select count(*) from hr.employees;

  COUNT(*)
----------
       107 New! Instructor-made content
https://logic.edchen.org/how-to-connect-a-pdb-directly-by-os-authentication/ 1/6
11/14/22, 9:07 AM Connect to PDB as SYSDBA by ORACLE_PDB_SID - Ed Chen Logic

A problem comes, how do we connect to the pluggable database (PDB) without any password?
Let's see the second case.

[oracle@test ~]$ sqlplus / as sysdba

...

SQL> show con_name

CON_NAME

------------------------------

CDB$ROOT

SQL> alter session set container=ORCLPDB;

Session altered.

SQL> show con_name

CON NAME

As you can see, we set container in session in order to get into PDB. Honestly, both cases are
somewhat inconvenient, we want to connect to the PDB directly by OS authentication without
password.

Use ORACLE_PDB_SID
Since 18c, we have another scheme to connect to a PDB directly without password. The secret
ingredient is set an additional environment variable ORACLE_PDB_SID to let Oracle know what
PDB we want to directly connect to.

[oracle@test ~]$ echo $ORACLE_SID

ORCLCDB

[oracle@test ~]$ export ORACLE_PDB_SID=ORCLPDB

[oracle@test ~]$ sqlplus / as sysdba

...

SQL> show con_name

CON_NAME

------------------------------

ORCLPDB

SQL> select count(*) from hr.employees;

  COUNT(*)

It's extremely useful when we want to directly export data from a PDB without providing any
password. Moreover, utilities that need authentication are all applicable to this case. For example,
using RMAN to backup tablespaces belong to a PDB.

Please note that, ORACLE_PDB_SID is a dependency of ORACLE_SID. That is, if there's no


ORACLE_SID, Oracle still have no idea where to go.

If you found that you still can't do this in 18c or 19c database, maybe you should consider to apply
Database Release Update (DBRU) on Oracle database 19c.

New! Instructor-made content


For releases before 18c, you may create a logon trigger to do it.

https://logic.edchen.org/how-to-connect-a-pdb-directly-by-os-authentication/ 2/6
11/14/22, 9:07 AM Connect to PDB as SYSDBA by ORACLE_PDB_SID - Ed Chen Logic

Ad removed.
Details

Tags: ALTER PLUGGABLE DATABASE Container Database (CDB) Database Release Update (DBRU)

ORACLE_PDB_SID ORACLE_SID OS Authentication Pluggable Database (PDB)

SHOW CON_NAME sqlplus

PREVIOUS NEXT

How to expdp PDB as SYSDBA How to Resolve ORA-39195: At least one schema in the
without Password TABLE_FILTER does not exist.

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

Comment *

Name *

Email *
New! Instructor-made content
https://logic.edchen.org/how-to-connect-a-pdb-directly-by-os-authentication/ 3/6
11/14/22, 9:07 AM Connect to PDB as SYSDBA by ORACLE_PDB_SID - Ed Chen Logic

Save my name, email, and website in this browser for the next time I comment.

POST COMMENT

Search This Website

Search for...

Bookmark This Page

★ By Pressing Ctrl + D

Recent Posts

How to Install PLUSTRACE Role

How to Install PLAN_TABLE Table

How to Rename User in Oracle

How to Rename Constraint in Oracle

How to Rename DataFile in Oracle

New! Instructor-made content


https://logic.edchen.org/how-to-connect-a-pdb-directly-by-os-authentication/ 4/6
11/14/22, 9:07 AM Connect to PDB as SYSDBA by ORACLE_PDB_SID - Ed Chen Logic

Give your
degree
your all

Subscribe

Categories

Select Category

Recent Comments

Ed Chen on How to Resolve ORA-00001: unique constraint violated

Ajit Kumar Singh on How to Resolve ORA-00001: unique constraint violated

Ed Chen on How to Resolve "Connected to an idle instance"

Ehab Mohamed on How to Resolve "Connected to an idle instance"

New! Instructor-made content


Ed Chen on How to Resolve "Connected to an idle instance"

https://logic.edchen.org/how-to-connect-a-pdb-directly-by-os-authentication/ 5/6
11/14/22, 9:07 AM Connect to PDB as SYSDBA by ORACLE_PDB_SID - Ed Chen Logic

Meta

Log in

Entries feed

Comments feed

Neve | Powered by WordPress


WordPress.org

New! Instructor-made content


https://logic.edchen.org/how-to-connect-a-pdb-directly-by-os-authentication/ 6/6

You might also like