How to Find Out Your Oracle Database Name

November 2, 2009

in Parameters, Scripts

Oracle Database Name

Oracle gives you a number of ways to know the name of the database you are connected to, from inside a SQL*Plus session. Here are three ways to find out your Oracle database name.

Through V$DATABASE

SQL> select name from V$database;

NAME
---------
XE

The above will work only if your login has access to V$DATABASE. This is generally accessible to DBA logins only. For non-DBA logins, you may need to grant SELECT on V$ views.

In case access to V$DATABASE cannot be granted to you, use one of the two publicly accessible methods below.

Through GLOBAL_NAME

GLOBAL_NAME has the default value of db_name + db_domain. This is publicly accessible to anyone logged in to the database.

SQL>
SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------

XE

Through dbms_utility.get_parameter_value

The function get_parameter_value in dbms_utility returns the value of a given init.ora parameter. In this case the parameter is DB_NAME

SQL> variable i number
SQL> variable dbname varchar2(30);
SQL>
SQL> begin
2       :i:=dbms_utility.get_parameter_value('db_name',:i,:dbname);
3   end;
4   /

PL/SQL procedure successfully completed.

SQL> print dbname

DBNAME
------------------------------------------------------
XE

Summary

Oracle gives you easy ways to find out your Oracle database name from inside a SQL*Plus session. This article demonstrates three ways, using:

  • V$DATABASE
  • GLOBAL_NAME
  • DBMS_UTILITY.GET_PARAMETER_VALUE

Similarly, here’s how to find your Oracle database version.

{ 4 comments… read them below or add one }

1 Meg September 14, 2019 at 6:57 pm

Very useful, thank you!

2 prasun karar December 11, 2019 at 3:01 pm

Consider you have configured multiple database on a server . How to view all these database name ?

3 DrCrave February 15, 2022 at 2:19 pm

Thank you very much 🙂

4 Megha December 19, 2022 at 4:57 pm

Thank you

Leave a Comment

Previous post:

Next post: