Re: PostgreSQL counterpart to DBMS_METADATA?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Tefft <mjtefft(at)hotmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL counterpart to DBMS_METADATA?
Date: 2012-01-17 15:03:23
Message-ID: 15576.1326812603@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michael Tefft <mjtefft(at)hotmail(dot)com> writes:
> I would like to extract the DDL to create a given object (tables, primarily) from the catalog. Is there an interface, query, etc. that will do this? I'd rather not craft the DDL myself.

DDL isn't actually stored in the catalogs anywhere; it has to be
reconstructed. The only complete solution to that problem is embodied
in pg_dump. Hence the short answer is "extract what you need from
pg_dump output". Depending on exactly what you need, you might be able
to get pg_dump to emit only the object definition(s) you want in the
first place. Another possibility that wouldn't involve editing a large
dump file is to dump to an archive file and then use pg_restore's -l
and -L options to obtain a customized selective restore script.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeroen van Dongen 2012-01-17 16:27:19 Possible bug in PL/Python?
Previous Message Raymond O'Donnell 2012-01-17 14:48:52 Re: [GENERAL] RE: [GENERAL] PostgreSQL counterpart to DBMS_METADATA?‏