Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to find database name?

Posted on 2003-02-25
9
Medium Priority
?
37,000 Views
Last Modified: 2012-06-27
I know oracle provides database_name function (actually it is "dbms_standard.database_name") to get database name.

But this function may not installed on server by default, does any one know other way of finding database name?
0
Comment
Question by:sollala
9 Comments
 
LVL 8

Expert Comment

by:Danielzt
ID: 8021176
select * from sys.v_$database

select * from sys.v_$database where name='db_name'

tnsnames.ora
init.ora

windows: registry
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE

UNIX: $env  
look for ORACLE_SID





0
 

Author Comment

by:sollala
ID: 8021322
I need sql query, not from env. Above sql query will not work for normal user, needs dba access
0
 
LVL 1

Expert Comment

by:roberttran
ID: 8021935
create a view that contains info from v$database and grant select for that user.

Hope it helps.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sollala
ID: 8022085
My application will run on any DB and will not have DBA access to modify grants.
0
 
LVL 4

Accepted Solution

by:
asimkovsky earned 75 total points
ID: 8022232
Try this:

select ora_database_name
from dual;



Andrew
0
 
LVL 8

Expert Comment

by:Danielzt
ID: 8022267
try this:

select global_name from global_name;
0
 
LVL 7

Expert Comment

by:Fayyaz
ID: 8023125
1).Open init.ora initialization parameter file
and check db_name= "          "
parameter this will tell u the database name.

or check this query

2) connect sys/change_on_install;
   select name from v$database;

Hope this will help

Fayyaz
0
 

Expert Comment

by:rashidahmedkhan
ID: 8024340
Try this

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

With warm regards
Rashid
0
 
LVL 2

Expert Comment

by:Datamonkey
ID: 8026660
all these things that have been said before work fine for users without any privileges:
select ora_database_name from dual;
select sys_context('userenv','db_name') from dual;
select global_name from global_name;

however, I don't understand the starting point of the question. dbms_standard should always be available in the database, it's created in dbmsstdx.sql which is one of the first things called by catproc.sql which should always have been run when the database was created.
If dbms_standard is not available, not being able to find out the database name should not be your greatest worry.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question