Home » SQL & PL/SQL » SQL & PL/SQL » How to find out which database I am using from the SQL Promt??
How to find out which database I am using from the SQL Promt?? [message #19598] Mon, 01 April 2002 00:59 Go to next message
Sreedhar
Messages: 30
Registered: March 2000
Member
Hi,

I am currently using 3 databases which are present on the same machine. I am using 'connect' command to switch between these databases. My problem is that sometimes I dont know in which database I am currently in. Because of this problem I sometimes update or delete rows in wrong database.

I want to know "Is there any command thru which I can find which database I am currently using from SQL Prompt??"

Thanks and Regards
Sreedhar
Re: How to find out which database I am using from the SQL Promt?? [message #19599 is a reply to message #19598] Mon, 01 April 2002 01:30 Go to previous messageGo to next message
Skumar
Messages: 17
Registered: April 2002
Junior Member
select * from V$database;

this query will give you the database you r workin on
you can set the database name as you sql prompt each time you connect using set sqlprompt 'YOURDATABASENAME'
Re: How to find out which database I am using from the SQL Promt?? [message #19629 is a reply to message #19598] Mon, 01 April 2002 23:34 Go to previous message
sonali vernekar
Messages: 8
Registered: March 2002
Junior Member
Connected to:
Oracle8 Enterprise Edition Release 8.0.4.0.0 - Production
With the Partitioning and Objects options
PL/SQL Release 8.0.4.0.0 - Production
08:35:10 HCIT>

HCIT is the SID of the database where I am currently connected. Every prompt indicates the time. So when SQL*Plus is done with one command it will display the new time on the prompt for next command. This tells you exactly when the previous command terminated.

How do you set SQL*Plus to do this?

Go to your oracle home directory. e.g.. d:orant.
Go to the SQL*Plus Directory. e.g.. Plus33, Plus80.
Edit or create file Glogin.sql
Add the following text at the end of the file:
set lines 100
set pages 100
set termout off
col dbname new_value prompt_dbname
select substr(global_name,1,instr(global_name,'.')-1) dbname
from global_name;
set sqlprompt "&&prompt_dbname> "
set termout on
set time on

i hope this solves ur query
Previous Topic: how to retrieve only rows X to Y from view
Next Topic: Oracle Little problem
Goto Forum:
  


Current Time: Thu Apr 18 04:38:06 CDT 2024