
But there is no PDB1 in my CDB2: $ sqlplus / as sysdba You’d think I’m connected to PDB1 obviously. Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Let’s do a little quiz – in which PDB am I connected now? $ export ORACLE_SID=CDB2 In all other cases, your connection won’t be rejected – but you’ll be placed into CDB$ROOT. But only in the case that you use the name of an existing PDB, you’ll be connected to it. You can use any PDB name – and you’ll be connected. But even I can see from looking at the lines above what happens when you connect with any PDB name, regardless if the PDB exists or not. As I received this question already (“How does it know to which PDB1 it should connect, in CDB1 or CDB2?”) I thought I clarify this here. ORACLE_PDB_SID does not work without the correct ORACLE_SID. The ORACLE_SID defines to which SID you connect to. Please be aware that the parameter ORACLE_PDB_SID works only in conjunction with ORACLE_SID.
Pdb database code#
You can query the code by yourself: SQL> select trigger_body from dba_triggers where trigger_name = 'DBMS_SET_PDB'ĭBMS_SYSTEM.get_env ('ORACLE_PDB_SID', pdb_name) ĮXECUTE IMMEDIATE 'alter session set container = ' || '"' || pdb_name || '"' The trigger fires when you logon as SYS or SYSTEM. And it works in XE as well – just for the records. It does not exist in Oracle Database 12.2.0.1 or Oracle 12.1.0.2.

This trigger most likely comes in with the April 2019 RUs for Oracle Database 19c and 18c. It is done with a trigger called DBMS_SET_PDB. THANKS so much – as I always repeat, this blog is luckily not a one-way street as I keep learning from you guys out there as well. But gladly, some of my readers knew already.

When I wrote the blog post Can you connect as SYSDBA without password into a PDB directly? I haven’t dug into the technique behind the ability of doing a sqlplus / as sysdba directly into a PDB without the password. Photo by Mauro Sbicego on Unsplash How does it work?
