Skip to content

Database Info (db.sql)

Displays basic database name, instance name, host name, and instance status in a single query.

rem db.sql
rem
ttitle 'Database and Instance Information'
rem
set lines 160
rem
clear col
col DATABASE format a12 heading 'DATABASE'
col INSTANCE format a12 heading 'INSTANCE'
col HOST format a22 heading 'HOST'
col STATUS format a12 heading 'STATUS'
rem
SELECT a.NAME DATABASE, upper(b.INSTANCE_NAME) INSTANCE, upper(b.HOST_NAME) HOST, b.STATUS STATUS
FROM v$database a, v$instance b
/
-- Basic usage
@db.sql

The script prompts for:

  • None - this script requires no parameters
SELECT ANY DICTIONARY
-- OR --
SELECT ON V$DATABASE
SELECT ON V$INSTANCE
DATABASE INSTANCE HOST STATUS
----------- ------------ -------------------- ------------
ORCL ORCL1 DB-SERVER-01 OPEN
  • DATABASE: Database name from V$DATABASE
  • INSTANCE: Instance name (uppercase)
  • HOST: Host/server name (uppercase)
  • STATUS: Current instance status (OPEN, MOUNTED, etc.)

Quick Environment Check

-- Verify which database and instance you're connected to
@db.sql

RAC Environment

-- Identify specific instance in a cluster
@db.sql