Обсуждение: pg_dump using SQL

Поиск
Список
Период
Сортировка

pg_dump using SQL

От
"Yusnel Rojas García"
Дата:
Hi everyone<br /><br />Is there any way to do what pg_dump does?, I mean, get the structure of a table in a database
(ex:CREATE TABLE ...)<br /><br />thanks in advance.<br /> 

Re: pg_dump using SQL

От
"Phillip Smith"
Дата:
> Is there any way to do what pg_dump does?, I mean, get the structure of a
table in a database (ex: CREATE TABLE ...)

Turn Query Logging on in postgresql.conf then see what queries are executed
by pgAdmin or similar when you run it?


THINK BEFORE YOU PRINT - Save paper if you don't really need to print this

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee.  If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments
e-mail.


Re: pg_dump using SQL

От
Tom Lane
Дата:
"Phillip Smith" <phillip.smith@weatherbeeta.com.au> writes:
>> Is there any way to do what pg_dump does?, I mean, get the structure of a
>> table in a database (ex: CREATE TABLE ...)

> Turn Query Logging on in postgresql.conf then see what queries are executed
> by pgAdmin or similar when you run it?

But note that these queries are moving targets: they frequently change
from one PG version to the next.

By far the best answer, if you can use it, is to invoke pg_dump itself
as a subprocess.  Something like "pg_dump -s -t mytable ..." for
instance.
        regards, tom lane


Re: pg_dump using SQL

От
Preston Landers
Дата:
Yusnel Rojas Garc?a(onemoverx@gmail.com)@2008.03.18 11:45:03 -0800:
> Hi everyone
> 
> Is there any way to do what pg_dump does?, I mean, get the structure of a
> table in a database (ex: CREATE TABLE ...)
> 

If you want to programmaticly discover the elements in a database
schema then you can always query the INFORMATION_SCHEMA:

http://www.postgresql.org/docs/current/static/information-schema.html

That isn't the same as having the raw DLL statements that created
them, but depending on your purpose may be good enough.

regards,
Preston