Re: Need SQL of create TABLE including INDEX and SEQUENCE

Поиск
Список
Период
Сортировка
От Francisco Leovey
Тема Re: Need SQL of create TABLE including INDEX and SEQUENCE
Дата
Msg-id 102564.31169.qm@web39302.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Need SQL of create TABLE including INDEX and SEQUENCE  (Francisco Leovey <fleovey@yahoo.com>)
Ответы Re: Need SQL of create TABLE including INDEX and SEQUENCE  (Vibhor Kumar <vibhor.kumar@enterprisedb.com>)
Список pgsql-novice

I am not sure I will understand the code inside PG_DUMP
 
I could call PG_DUMP and store the info on a text file and then read it into my program and then issue an SQL command
But I was hoping to get the info directly from the Postgres tables using some fancy query.
 
I am using some queries that give me a list of tables and a list of fields in a table but now I need the actual SQL as shown on PgAdmin
 
Maybe somebody knows the way PgAdmin generates it
 


--- On Mon, 4/11/11, Michael Glaesemann <grzm@seespotcode.net> wrote:

From: Michael Glaesemann <grzm@seespotcode.net>
Subject: Re: [NOVICE] Need SQL of create TABLE including INDEX and SEQUENCE
To: "Francisco Leovey" <fleovey@yahoo.com>
Cc: pgsql-novice@postgresql.org
Date: Monday, April 11, 2011, 1:06 PM


On Apr 11, 2011, at 7:55, Francisco Leovey wrote:

> Hello

> For a new project where I am running 2 versions of Postgres (8.4 and 9.0) simultaneously on an Ubuntu server:
> I need the syntax of an SQL statement in order to create tables and all index from one database to the other via a utility program I have in Perl.
> I see PgAdmin shows on the lower pane all the SQL needed to create a table and all its index, but I do not know how to obtain that info.
> It would be optimal if I can get all the info in a single query (the way pgdump does).
> Also I need the SQL to create all the SEQUENCES.

Can you call pg_dump?

pg_dump -s -t your_table

Otherwise, I recommend taking a look at the pg_dump source code.

Michael Glaesemann
grzm seespotcode net



В списке pgsql-novice по дате отправления:

Предыдущее
От: Mathieu Dubois
Дата:
Сообщение: Re: What does \timing measure?
Следующее
От: "Saseendra Babu"
Дата:
Сообщение: 'Range partitioning in PGSQL'