pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
CREATE TABLES AS looses constraints
2+ messages / 2 participants
[nested] [flat]

* CREATE TABLES AS looses constraints
@ 2003-05-29 16:35 Tiaan Wessels <tiaan@netsys.co.za>
  2003-05-29 20:48 ` Re: CREATE TABLES AS looses constraints Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Tiaan Wessels @ 2003-05-29 16:35 UTC (permalink / raw)
  To: pgsql-sql

Hi,
It seems as if a CREATE TABLES AS does not duplicate the table constraints. 
How can I enforce this. I need the fastest possible way to make an exact copy 
of a table. This is to support the administrative mechanism in an app where 
changes are made to a mirrored copy of a set of tables first and when happy, 
these are copied to the operational tables.
Regards
Tiaan



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: CREATE TABLES AS looses constraints
  2003-05-29 16:35 CREATE TABLES AS looses constraints Tiaan Wessels <tiaan@netsys.co.za>
@ 2003-05-29 20:48 ` Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2003-05-29 20:48 UTC (permalink / raw)
  To: Tiaan Wessels <tiaan@netsys.co.za>; pgsql-sql

Tiaan,

> It seems as if a CREATE TABLES AS does not duplicate the table constraints. 
> How can I enforce this. I need the fastest possible way to make an exact 
copy 
> of a table. This is to support the administrative mechanism in an app where 
> changes are made to a mirrored copy of a set of tables first and when happy, 
> these are copied to the operational tables.

I suggest using pg_dump, on the command line:

pg_dump -T some_table my_database > some_table.pgdump;
psql -U database_owner my_database_mirror < some_table.pgdump;

This will copy triggers and indexes as well.

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-05-29 20:48 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-05-29 16:35 CREATE TABLES AS looses constraints Tiaan Wessels <tiaan@netsys.co.za>
2003-05-29 20:48 ` Josh Berkus <josh@agliodbs.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