Instance, host and service
When to use it
Before any other work, and whenever someone asks "which database is this?".
Run this
Script: 01_show_instance_info.sql. Full version in Performance › Performance monitoring › Instance info.
col "Instance" format a25
col "Hostname" format a25
col "Service" format a25
select sys_context('userenv', 'instance_name') as "Instance",
sys_context('userenv', 'server_host') as "Hostname",
sys_context('userenv', 'service_name') as "Service"
from dual;
Starter query written for this guide:
SELECT inst_id, instance_name, host_name, version, startup_time, status
FROM gv$instance
ORDER BY inst_id;
How to read the output
- One row per instance. More than one row means this is a RAC database, and your session is on only one of the nodes.
startup_timetells you when the instance last started. A recent time that nobody planned is worth asking about.- Views that start with
gv$show all RAC instances; views that start withv$show only yours.
What to do next
- Write the instance and host in your notes before you continue.
- On RAC, remember that a session id is only unique together with the instance id.
Risk level
READ ONLY Safe to run at any time. It only queries the data dictionary.