When you are bouncing between instances as an Oracle DBA, what is a quick way to determine what instance you are in? You certainly don't want to drop tables, tablespaces, etc. in the wrong instance. I've found these simple queries an easy way to quickly determine what instance you are working on.
Many times I am bouncing in and out of a variety of Oracle instances. A quick and dirty trick I have used (as a user with DBA role) is to check the instance name using one of these two select commands:
select * from v$instance; or select * from v$database;It's saved my posterior quite a few times in that I was about to mangle tables, data, etc. This tip has been used on Oracle 8.x and 7.3.4.
Reader Feedback
Jon H. writes: Agreed, this is a good way to determine which instance you (a DBA) are in. What I find to be better is:
select name from v$database;
This saves the hassle of looking through all the fields to recognise which database you are in. For other users, like developers and programmers who do not have DBA privileges, they can use:
select * from global_name;
These are tips I use on a daily basis and they have prevented some disasters from happening.
Niranjan writes: Why do you need to display all the other column data with * ? It would be better to get instance_name from v$instance or name from v$database.
DeniseC. writes: Why "select
Requires Free Membership to View
RobertG. writes: Why not just use 'show parameter db_name' ?
AndrewR. writes: Yes, "quick and dirty" is right. I prefer to run a little script at each connect that changes the SQL> prompt so that the SID evidence is always at hand. The script is as follows:
set termout off set time on col new_prompt new_value new_prompt_value SELECT user||':'||substr(global_name,1,instr(global_name||'.','.',1)-1) new_prompt FROM global_name ; set sqlprompt '&new_prompt_value> ' set termout on
It should be noted that I acquired this script off a newsletter similar to this -- or it might even have been this one. I have been using it for quite a while.
For More Information
- Feedback: E-mail the editor with your thoughts about this tip.
- More tips: Hundreds of free Oracle tips and scripts.
- Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
- Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.
- Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
- Best Web Links: Oracle tips, tutorials, and scripts from around the Web.
This was first published in August 2002
Join the conversationComment
Share
Comments
Results
Contribute to the conversation