In this Oracle Tutorial, we will talk about 3 simple ways to find Oracle database name. Let us go through them one by one.
This page contains (Skip to topic)..
Find Oracle Database Name with V$DATABASE
select name from V$database;
NAME --------- ORCL
Well, this v$database is not accessible to all db users. Generally, only dba people have SELECT permission to this. However, if you want to access v$database and you are not able to, you need to ask your database administrator to GRANT SELECT on V$ views. However, there are two other ways for the NON-DBA Users listed below.
Find Oracle DB Name with GLOBAL_NAME
This is the simplest of all. All you need to do is use the following query.
select global_name from global_name; GLOBAL_NAME ------------ ORCL
Find Oracle DB Name with dbms_utility.get_parameter_value
get_parameter_value is a function in dbms_utility. We can get the parameter values in init.ora file. We will extract the value of parameter DB_NAME to find Oracle database name.
set serveroutput on declare i number; dbname varchar2(30); begin i := dbms_utility.get_parameter_value('db_name',i,dbname); dbms_output.put_line(dbname); end; /
The result of the above script is,
orcl PL/SQL procedure successfully completed.
What did we learn in this Oracle Tutorial?
We covered 3 ways to find Oracle database name. For DBA Users
- Using the v$database
For non-dba users ( or public access ways),
- Using global_name
- Using dbms_utility.get_parameter_value