Thread: PostgreSQL counterpart to DBMS_METADATA?
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.
Thanks,
Mike
On Tue, Jan 17, 2012 at 04:53:42AM -0600, Tefft, Michael J wrote: > 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. use pg_dump -t table_name -s Best regards, depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/
Any suggestions for doing this from PL/pgSQL? -----Original Message----- From: depesz@depesz.com [mailto:depesz@depesz.com] Sent: Tuesday, January 17, 2012 6:25 AM To: Tefft, Michael J Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] PostgreSQL counterpart to DBMS_METADATA? On Tue, Jan 17, 2012 at 04:53:42AM -0600, Tefft, Michael J wrote: > 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. use pg_dump -t table_name -s Best regards, depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/
On 17/01/2012 12:58, Tefft, Michael J wrote: > Any suggestions for doing this from PL/pgSQL? If you run psql with the -E option, and then do various \d commands to examine database objects, it will output the queries it generates to get metadata - you can then adapt these to your own needs. Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie