Skip to content

Conversation

@akshay-joshi
Copy link
Owner

This adds a new system function, pg_get_database_ddl(database_name/database_oid, pretty), which reconstructs the CREATE DATABASE statement for a given database name or database oid.

Usage:
SELECT pg_get_database_ddl('postgres'); // Non pretty-formatted DDL
SELECT pg_get_database_ddl(16835); // Non pretty-formatted DDL
SELECT pg_get_database_ddl('postgres', true); // pretty-formatted DDL
SELECT pg_get_database_ddl(16835, true); // pretty-formatted DDL

Reference: PG-150
Author: Akshay Joshi akshay.joshi@enterprisedb.com
Reviewed-by: Álvaro Herrera alvherre@kurilemu.de

@akshay-joshi akshay-joshi force-pushed the get_database_ddl branch 9 times, most recently from 25bd4ed to cfbbcd4 Compare November 17, 2025 07:44
@akshay-joshi akshay-joshi force-pushed the get_database_ddl branch 5 times, most recently from 76b4776 to 8ea45bf Compare November 20, 2025 08:37
…tements.

This adds a new system function, pg_get_database_ddl(database_name/database_oid, pretty),
which reconstructs the CREATE DATABASE statement for a given database name or database oid.

Usage:
  SELECT pg_get_database_ddl('postgres'); // Non pretty-formatted DDL
  SELECT pg_get_database_ddl(16835); // Non pretty-formatted DDL
  SELECT pg_get_database_ddl('postgres', true); // pretty-formatted DDL
  SELECT pg_get_database_ddl(16835, true); // pretty-formatted DDL

Reference: PG-150
Author: Akshay Joshi <akshay.joshi@enterprisedb.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants