Report the Name of the Current Database Instance

Sometimes, you need to know the Oracle database instance name on which your SQL is being executed. For instance, say you have to print a DBA report for which you have prepared a set of scripts, and which you want to execute on each database. You also want the name of the database instance at the top of report, followed by statistics for that. Of course, you don’t want to change the script for each instance?you want a generic script.

To get the name of the Oracle instance, query the GLOBAL_NAMES view in Oracle, like this:

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: