Often you want to find out what the database is that you are logged in to. This can be useful when spooling the output of a SQL script to a log file or checking you are in the right environment before executing a script.
Oracle
In Oracle you can get the current database name by querying the table v_$database
i.e.
select name
from sys.v_$database
SQL Server
The equivalent way of finding it in SQL Server is to use the function DB_Name.
e.g.
select DB_Name()
No comments:
Post a Comment