V$INSTANCE is a dynamic performance view in PolarDB for PostgreSQL (Compatible with Oracle) that returns the current status of the database cluster. Query it to check whether the cluster is running, identify its role, and retrieve basic configuration details such as version and host name.
Querying V$INSTANCE requires a privileged account.Columns
| Column | Type | Description |
|---|---|---|
| INSTANCE_NUMBER | numeric | The cluster number. |
| INSTANCE_NAME | character varying (16) | The cluster name, which is usually the same as the database name. |
| HOST_NAME | character varying (16) | The host name of the database cluster. |
| VERSION | character varying (17) | The database version. |
| STARTUP_TIME | date | The time when the cluster was started. |
| STATUS | character varying (12) | The current status of the cluster, such as OPEN, MOUNTED, and STARTED. |
| PARALLEL | character varying (3) | Specifies whether the cluster is running in parallel mode. |
| THREAD# | numeric | The thread serial number of the cluster. |
| ARCHIVER | character varying (7) | The archiving status of the cluster. |
| LOG_SWITCH_WAIT | character varying (15) | The event that log switching is waiting for. |
| DATABASE_STATUS | character varying (17) | The database status, such as ACTIVE and SUSPENDED. |
| INSTANCE_ROLE | text | The role of the cluster, such as PRIMARY INSTANCE and SECONDARY INSTANCE. |
Usage example
Use the following query to check whether the cluster is running and available:
SELECT instance_name, status, database_status, instance_role
FROM V$INSTANCE;