Re: CREATE TABLES AS looses constraints

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Tiaan Wessels <tiaan(at)netsys(dot)co(dot)za>, pgsql-sql(at)postgresql(dot)org
Subject: Re: CREATE TABLES AS looses constraints
Date: 2003-05-29 20:48:01
Message-ID: 200305291348.01440.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message George Weaver 2003-05-29 21:29:39 Re: "record" datatype - plpgsql
Previous Message Chadwick Rolfs 2003-05-29 19:53:14 Re: [SQL] faster output from php and postgres (one resolution)