Skip to content
Home » Oracle Database » Which Container Am I Using? Where Am I?

Which Container Am I Using? Where Am I?

You may find out there're too many PDB to make you manage them well, waste time to execute useless statements, or get lost in container forest.
SQL> alter session set container = XXX;

Session altered.

SQL> --Doing something ...

SQL> alter session set container = YYY;

Session altered.

SQL> --Doing something ...

SQL> alter session set container = ZZZ;

Session altered.

SQL> --Doing something ...

In worse cases, you may mistakenly issue destructive operations like truncate table statement in the wrong container.

So the best practice is that you should confirm which container you are using currently before doing the critical statements with cautiousness.

But how do we know which container I am using currently? This is quite simple.
SQL> show con_name;

CON_NAME
------------------------------
FINA_PDB

SQL> show pdbs;

    CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
3 FINA_PDB  READ ONLY  NO

SQL>

The best thing is that you know what open mode you are in. READ ONLY is quite safe for normal operations.

You may not have to know which container you are in. Just set the container to the target PDB directly to proceed your operation.

Leave a Reply

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