Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements

Marcos Pegoraro <marcos@f10.com.br>

From: Marcos Pegoraro <marcos@f10.com.br>
To: Akshay Joshi <akshay.joshi@enterprisedb.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-06-08T19:11:05Z
Lists: pgsql-hackers
Em seg., 8 de jun. de 2026 às 08:30, Akshay Joshi <
akshay.joshi@enterprisedb.com> escreveu:

> Hi Hackers,
>
> Attached is the v2 patch, which fixes the Meson build failure, and the
> rebased patch.
>

Would be good to have an option "schema-qualified" boolean, because
sometimes I don't want a schema-qualified result.
Suppose you are duplicating a schema, the way your did you cannot do
something like this to have a complete script to generate a new schema

select 'create schema new_schema;' union all
select 'set search_path to new_schema, public;' union all
select string_agg(pg_get_table_ddl(oid),',') from pg_class where
relnamespace::regnamespace::text = 'old_schema' and relkind = 'r';

regards
Marcos