From: | Francisco Leovey <fleovey(at)yahoo(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Need SQL of create TABLE including INDEX and SEQUENCE |
Date: | 2011-04-11 18:24:13 |
Message-ID: | 102564.31169.qm@web39302.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)seespotcode(dot)net> wrote:
From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
Subject: Re: [NOVICE] Need SQL of create TABLE including INDEX and SEQUENCE
To: "Francisco Leovey" <fleovey(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2011-04-11 20:30:52 | Re: 'Range partitioning in PGSQL' |
Previous Message | Mathieu Dubois | 2011-04-11 17:19:09 | Re: What does \timing measure? |