Close

SYS_CONTEXT DB_NAME bug fixed in 12cR2

A few years ago I wrote a small article about finding the various name of a database through different means. One of which was SYS_CONTEXT with the USERENV namespace. At the time (April 2016) the latest version of the Oracle database as 12cR1 where a query like this:

select SYS_CONTEXT('userenv','db_name') from dual;

Would return the CONTAINER name, even if you were logged into the pluggable db or set your session’s container to a pdb.

However, as of 12cR2 or with patch 22743059, SYS_CONTEXT will now return the pluggable db’s name as expected.

I’ll be going back and updating the old article with this new information as well.