select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / SYSTEM INFORMATION FUNCTIONS AND OPERATORS

pg_get_database_ddl

Read PG 20 devel manual ↗

Reconstructs the CREATE DATABASE statement for the specified database, followed by ALTER DATABASE statements for connection limit, template status, and configuration settings.

Development snapshot. These definitions may change before release.

Signatures & examples

pg_get_database_ddl ( database regdatabase [, pretty boolean DEFAULT false] [, owner boolean DEFAULT true] [, tablespace boolean DEFAULT true] ) → setof text
Reconstructs the CREATE DATABASE statement for the specified database, followed by ALTER DATABASE statements for connection limit, template status, and configuration settings. Each statement is returned as a separate row. When pretty is true, the output is pretty-printed. When owner is false, the OWNER clause is omitted. When tablespace is false, the TABLESPACE clause is omitted.
Version history 1
  1. PG 18 → 19added

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source