Learning something new every day is the best part of my job. And as you can see and read on the blog, thanks to YOU, I learn a lot. This one I learned from Johannes Ahrends at my workshop for ora2know in Munich in early July this year. Were you aware of the two hidden columns in CDB-Views? I confess honestly: I wasn’t.

Photo by Steinar Engeland on Unsplash
Two hidden columns?
Johannes asked me whether I know the reason for the two hidden columns in every CDB-view. His question was more like: It’s super-useful but why are these hidden? I did not even know what he was talking about. But we’ve exchanged emails the following day.
I was hooked up immediately and needed to investigate a bit more.
At first, I tried out a few things, and there they are, the two hidden columns:
- CON$NAME
- CDB$NAME
As Johannes, told me, they are in in every CDB_* view I checked. And as he praised, they are quite useful saving you one or the other join making queries easier, and potentially even faster due to the absence of an unnecessary join. I was really surprised. And I am fully aware that some of you may now smile and say: Under which rock has Mike lived the past years? Maybe … but for others it may be helpful to know.
Of course, I found blog posts about it written a while back. But even better, it is officially documented in the Oracle documentation. For instance, here in the 19c docs:
How could I miss this? Well, it is easy to not recognize this little paragraph:
CDB_* views include these hidden columns:
-
CON$NAME: This column includes the name of the container whose data a given CDB_* row representsCDB$NAME: This column displays the name of the CDB whose data a given CDB_* row represents
That’s neat – and important.
Why hidden?
To be frank, I don’t know. But I have an idea. From a search in our bugDB I quickly found some interesting references. Without checking the code it looks to me as if this came in in Oracle Database 12.2.0.1. The reason for these hidden columns seems to be related to the CONTAINERS clause allowing to read data with one single SQL from various containers or PDBs.
When we discussed this internally in our team, Rodrigo immediately commented that those columns aren’t listed in DBA_TAB_COLUMNS, or anywhere else. And I found a hint for the reason why that is:
“These columns will continue to be hidden but they will not be marked as invisible.”
Some coding had been done to keep them hidden but not list them as invisible. Quite an interesting way to do things.
How can you use them?
Since the columns are there, you certainly are free to use them – especially since they are even documented in our documentation.
Let me take a simple query from my blog:
select CON_ID, DIRECTORY_NAME, DIRECTORY_PATH from CDB_DIRECTORIES where DIRECTORY_NAME='DATA_PUMP_DIR' order by CON_ID, DIRECTORY_NAME ;
The result looks like:
CON_ID DIRECTORY_NAME DIRECTORY_PATH
_________ _________________ ________________________________________________________________________
1 DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/
3 DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/3BA33326F4C4F5BCE0634B00000A6175
4 DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/3BA33326F4C6F5BCE0634B00000A6175
5 DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/3BA33326F4C8F5BCE0634B00000A6175
But what if I want to see each container‘s name?
Then I need a join since the name of the PDB or root container is not in CDB_DIRECTORIES (I thought). This may lead to an imperfect query with an extra join, such as:
select d.CON_ID, p.NAME, d.DIRECTORY_NAME, d.DIRECTORY_PATH
from CDB_DIRECTORIES d, V$PDBS p
where d.DIRECTORY_NAME='DATA_PUMP_DIR' and
d.CON_ID=p.CON_ID
order by CON_ID, DIRECTORY_NAME
;
giving me this result (where CDB$ROOT is now missing):
CON_ID NAME DIRECTORY_NAME DIRECTORY_PATH
_________ ________ _________________ ________________________________________________________________________
3 RED DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/3BA33326F4C4F5BCE0634B00000A6175
4 BLUE DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/3BA33326F4C6F5BCE0634B00000A6175
5 GREEN DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/3BA33326F4C8F5BCE0634B00000A6175
Not ideal – and complex.
If I’d known about the hidden columns before, it would have been much simpler (and quicker):
select CON_ID, CON$NAME, DIRECTORY_NAME, DIRECTORY_PATH from CDB_DIRECTORIES where DIRECTORY_NAME='DATA_PUMP_DIR' order by CON_ID, DIRECTORY_NAME ;
By adding one additional column only (CON$NAME), I change the output to what I really want to see:
CON_ID CON$NAME DIRECTORY_NAME DIRECTORY_PATH
_________ ___________ _________________ ________________________________________________________________________
1 CDB$ROOT DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/
3 RED DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/3BA33326F4C4F5BCE0634B00000A6175
4 BLUE DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/3BA33326F4C6F5BCE0634B00000A6175
5 GREEN DATA_PUMP_DIR /u01/app/oracle/product/23/rdbms/log/3BA33326F4C8F5BCE0634B00000A6175
No unnecessary join anymore. And even CDB$ROOT is still there.
It could have been that easy.
Thanks, Johannes – and apologies to everyone who knew this for years smiling now.
Update:
Thanks to Birgit for telling me, these are documented now:
https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/cdb_-views.html
Further Links and Information
–Mike
that is a nice one but as you said I am really curious now why they are hidden. I replaced around 20 queries already which has joins to get pdb name. many thanks for sharing Mike.
Hi Mustafa,
I have a feeling why it is handled this way ..
And glad if it eases things. I did the same, and “tweak” some queries right away making them much easier to read.
Thanks,
Mike
good to know it is there, but how about the concept of a relational database?
Umph … 🙂
Mike
Join with v$containers instead of v$pdbs and you will see CDB$ROOT too.
But of course, CON$NAME and CDB$NAME are much easier 🙂
Oh thanks – I tried with a DBA view but forgot about v$sontainers – thanks!!!
Cheers,
Mike
Another useful trick is
select a.*,con$name,cdb$name from cdb_directories a
This allows us to simply append them to our sql without specifying the actual column names.
Thanks for sharing!!
CHeers,
Mike
I know I am a little late, but maybe the information still is helpful for some:
function con_id_to_con_name() also could be used to convert con_id’s to names, and also can be used in places where column CON$NAME is not available
https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/con_id_to_con_name.html
Cheers,
Manuela
Thanks Manuela!
Cheers,
Mike
based on @Manuela Dietze’s reply, it is very interesting that, you can get other pdb names in a pdb using con_id_to_con_name() function! even the deleted pdb’s names can be accessed (if their pdb id is not used). seems like a little bit backdoor.
Well, I would call it more like a hack – but I really don’t know.
An Oracle partner from Germany showed me this at an workshop in Munich, and I was quite surprised.
Cheers,
Mike
Hey Mike, now the mentioned hidden columns are documented (update of the documentation in February 2026), see here:
https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/cdb_-views.html
Regards,
Birgit
Thank you!
Mike