Re: Need SQL of create TABLE including INDEX and SEQUENCE

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Francisco Leovey <fleovey(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Need SQL of create TABLE including INDEX and SEQUENCE
Date: 2011-04-11 16:06:34
Message-ID: 3A657E38-E3F3-4D06-A841-281523F8E3B4@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Mathieu Dubois 2011-04-11 17:19:09 Re: What does \timing measure?
Previous Message Francisco Leovey 2011-04-11 11:55:00 Need SQL of create TABLE including INDEX and SEQUENCE