Return a human-readable string describing the engine version.
VERSION()
## Overview Returns a human-readable string describing the running engine version. Use this function in diagnostics, support bundles, and compatibility probes. ## Session context - The value is fixed for the lifetime of the process and does not change mid-session. - Takes no arguments. - Never returns NULL. ## Behavior - Always returns a non-NULL string. - Deterministic for the duration of the process. - Side effect free. ## Compatibility - PG-compat alias for the standard engine version string.
-- Read the engine version
SELECT VERSION();
-- Include version in a diagnostics query
SELECT VERSION() AS engine_version,
CURRENT_DATABASE() AS db,
CURRENT_USER() AS user_name;
-- Log version alongside server start time for troubleshooting
SELECT VERSION() AS v, PG_POSTMASTER_START_TIME() AS started;
-- Persist the observed engine version on a snapshot row
INSERT INTO ops.audit.env_snapshots (taken_at, engine) VALUES (CURRENT_TIMESTAMP, VERSION());