Here is a quick way to get the database name, operating system user, and database session user using Oracle’s SYS_CONTEXT function.  I use these values in my queries when I want to capture additional information in the result set.  The database name value comes in handy – especially when working in multiple environments.

You can add these fields to your existing select statement – no additional reference is needed.

To test these you can use the following query:

Result set from the above query:
result

 

If you are interested in learning more about the SYS_CONTEXT function, check out this article from TechOnTheNet.com.

 

Leave a Reply

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

 

 

*