Home » SQL & PL/SQL » SQL & PL/SQL » How to check the database name before executing DDL statements??
How to check the database name before executing DDL statements?? [message #19602] Mon, 01 April 2002 05:52 Go to next message
Sreedhar
Messages: 30
Registered: March 2000
Member
Hi,

I am currently using 3 databases on same machine. I got DDL scripts to drop/create tables/views.

Is there anyway to check for the database name before executing DDL scripts???? I want to incorporate this check into script itself, so that I dont have to worry which database I am using. If I am using the wrong database, script should exit saying 'Wrong Database'.

Thanks and Regards
Sreedhar
Re: How to check the database name before executing DDL statements?? [message #19603 is a reply to message #19602] Mon, 01 April 2002 06:18 Go to previous messageGo to next message
Cindy
Messages: 88
Registered: November 1999
Member
Try this:

select name from v$database;
Re: How to check the database name before executing DDL statements?? [message #19624 is a reply to message #19603] Mon, 01 April 2002 22:42 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: math
Next Topic: How to check the database name before executing DDL statements(without using PL/SQL)??
Goto Forum:
  


Current Time: Thu Mar 28 06:46:13 CDT 2024