26 November 2020

Logon as sysdba directly on PDB

This is a short version of https://mikedietrichde.com/2020/05/07/can-you-connect-as-sysdba-without-password-into-a-pdb-directly/

First the normal situation:

[oracle@dbhost01 ~]$ env|grep SID
ORACLE_SID=CDB01
[oracle@dbhost01 ~]$ sqlplus / as sysdba

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> select name from v$pdbs;

NAME
------------------------------
PDB$SEED
PDB01

SQL> exit

Now in your shell, set the variable ORACLE_PDB_SID

[oracle@dbhost01 ~]$ export ORACLE_PDB_SID=PDB01
[oracle@dbhost01 ~]$ sqlplus / as sysdba

SQL> show con_name

CON_NAME
------------------------------
PDB01

SQL> exit

If you want to get in the root, unset it, or set ORACLE_PDB_SID=CDB$ROOT

[oracle@dbhost01 ~]$ unset ORACLE_PDB_SID
[oracle@dbhost01 ~]$ sqlplus / as sysdba

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

So that gives you the opportunity to directly go to the PDB.

No comments:

Post a Comment