pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Tiaan Wessels <tiaan@netsys.co.za>
To: pgsql-sql@postgresql.org
Subject: Re: CREATE TABLES AS looses constraints
Date: Thu, 29 May 2003 13:48:01 -0700
Message-ID: <200305291348.01440.josh@agliodbs.com> (raw)
In-Reply-To: <20030529163556.7EBDE925D04@developer.postgresql.org>
References: <20030529163556.7EBDE925D04@developer.postgresql.org>

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




view thread (2+ messages)

Message-ID: <200305291348.01440.josh@agliodbs.com>
Permalink:  ../200305291348.01440.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200305291348.01440.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, tiaan@netsys.co.za
  Subject: Re: CREATE TABLES AS looses constraints
  In-Reply-To: <200305291348.01440.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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