Connecting to a Pluggable DB as SYSDBA

Introduction

So after years of putting it off you have finally taken the plunge and moved to a multitenant infrastructure.

You have created your 3 licence free pluggable database - MyDB1, MyDb2 and MyDb3.

You have copied all your scripts down onto the server. Then it suddenly hits you. Nearly all your scripts have sqlplus / as sysdba. . Hmmm. You wonder.

You test them and sure enough they dont work. They are all connectioning to the container DB and not the pluggable DB.

The Fix

Dont panic, the fix is very simple. Amend your scripts to set the following variable ORACLE_PDB_SID

export ORACLE_PDB_SID=MyDB1
sqlplus / as sysbda
SQL> show con_name
 
CON_NAME
--------------------------------------
MyDb1
 
SQL> exit
 
export ORACLE_PDB_SID=MyDB2
sqlplus / as sysbda
SQL> show con_name
 
CON_NAME
--------------------------------------
MyDb2

Published 1st December 2021

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License