pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedDumping table definitions
4+ messages / 4 participants
[nested] [flat]
* Dumping table definitions
@ 2005-07-18 16:50 Mark Fenbers <Mark.Fenbers@noaa.gov>
0 siblings, 3 replies; 4+ messages in thread
From: Mark Fenbers @ 2005-07-18 16:50 UTC (permalink / raw)
To: pgsql-sql
I am looking for a way to reformat the information that is generated from
\d mytable
into SQL syntax, such that the table can be recreated with 'psql -f
mytable.sql' complete with index and constraint definitions. I can do
awk and sed commands to do this if I need to, but first wanted to check
if Pg already had tools to export the table structure (without the
data). Does it?
Also, Is there a way to export the structure of all tables at once
instead of one table at a time?
Mark
Attachments:
Mark.Fenbers.vcf (text/x-vcard, 281B) download
begin:vcard
fn:Mark Fenbers
n:Fenbers;Mark
org:DoC/NOAA/NWS/OHRFC
adr:;;1901 South SR 134;Wilmington;OH;45177-9708;USA
email;internet:Mark.Fenbers@noaa.gov
title:Sr. HAS Meteorologist
tel;work:937-383-0430 x246
x-mozilla-html:TRUE
url:http://weather.gov/ohrfc
version:2.1
end:vcard
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Dumping table definitions
@ 2005-07-18 16:56 Jim Buttafuoco <jim@contactbda.com>
parent: Mark Fenbers <Mark.Fenbers@noaa.gov>
2 siblings, 0 replies; 4+ messages in thread
From: Jim Buttafuoco @ 2005-07-18 16:56 UTC (permalink / raw)
To: Mark Fenbers <Mark.Fenbers@noaa.gov>; pgsql-sql
use pg_dump with the --schema-only and --table= params
---------- Original Message -----------
From: "Mark Fenbers" <Mark.Fenbers@noaa.gov>
To: Pg SQL Discussion Group <pgsql-sql@postgresql.org>
Sent: Mon, 18 Jul 2005 12:50:54 -0400
Subject: [SQL] Dumping table definitions
> I am looking for a way to reformat the information that is generated from
> \d mytable
> into SQL syntax, such that the table can be recreated with 'psql -f
> mytable.sql' complete with index and constraint definitions. I can do
> awk and sed commands to do this if I need to, but first wanted to check
> if Pg already had tools to export the table structure (without the
> data). Does it?
>
> Also, Is there a way to export the structure of all tables at once
> instead of one table at a time?
>
> Mark
------- End of Original Message -------
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Dumping table definitions
@ 2005-07-18 16:56 Tom Lane <tgl@sss.pgh.pa.us>
parent: Mark Fenbers <Mark.Fenbers@noaa.gov>
2 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2005-07-18 16:56 UTC (permalink / raw)
To: Mark Fenbers <Mark.Fenbers@noaa.gov>; +Cc: pgsql-sql
"Mark Fenbers" <Mark.Fenbers@noaa.gov> writes:
> I am looking for a way to reformat the information that is generated from
> \d mytable
> into SQL syntax, such that the table can be recreated with 'psql -f
> mytable.sql' complete with index and constraint definitions. I can do
> awk and sed commands to do this if I need to, but first wanted to check
> if Pg already had tools to export the table structure (without the
> data). Does it?
pg_dump with the -s switch is a much better way ...
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Dumping table definitions
@ 2005-07-18 17:08 Dawid Kuroczko <qnex42@gmail.com>
parent: Mark Fenbers <Mark.Fenbers@noaa.gov>
2 siblings, 0 replies; 4+ messages in thread
From: Dawid Kuroczko @ 2005-07-18 17:08 UTC (permalink / raw)
To: Mark Fenbers <Mark.Fenbers@noaa.gov>; +Cc: pgsql-sql
On 7/18/05, Mark Fenbers <Mark.Fenbers@noaa.gov> wrote:
> I am looking for a way to reformat the information that is generated from
> \d mytable
> into SQL syntax, such that the table can be recreated with 'psql -f
> mytable.sql' complete with index and constraint definitions. I can do
> awk and sed commands to do this if I need to, but first wanted to check
> if Pg already had tools to export the table structure (without the
> data). Does it?
pg_dump is your friend! Use option -s (--schema-only).
It will dump the information you want. :-)
Regards,
Dawid
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2005-07-18 17:08 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-18 16:50 Dumping table definitions Mark Fenbers <Mark.Fenbers@noaa.gov>
2005-07-18 16:56 ` Jim Buttafuoco <jim@contactbda.com>
2005-07-18 16:56 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-07-18 17:08 ` Dawid Kuroczko <qnex42@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox