Skip site navigation (1) Skip section navigation (2)

Re: Need SQL of create TABLE including INDEX and SEQUENCE

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: (view raw, whole thread or download thread mbox)
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


pgsql-novice by date

Next:From: Michael GlaesemannDate: 2011-04-11 20:30:52
Subject: Re: 'Range partitioning in PGSQL'
Previous:From: Mathieu DuboisDate: 2011-04-11 17:19:09
Subject: Re: What does \timing measure?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group