version
→ textReturns a string describing the PostgreSQL server version and build information.
Signature
version ( ) → textExamples
SELECT version();PostgreSQL 18.0 on x86_64-pc-linux-gnu, compiled by gcc...SELECT regexp_match(version(), 'PostgreSQL (\d+\.\d+)')[1];18.0For programmatic version checks, use `current_setting('server_version_num')::integer` to get a numeric version (e.g., 180000 for 18.0.0). This is easier to compare than parsing the version() string.
SELECT current_setting('server_version_num')::integer >= 160000 AS is_pg16_or_later;true on PostgreSQL 16+