Re: Building a database from a flat file - Mailing list pgsql-sql

From Casey T. Deccio
Subject Re: Building a database from a flat file
Date
Msg-id 1109875028.12428.98.camel@boomerang.ran.sandia.gov
Whole thread Raw
In response to Re: Building a database from a flat file  (Markus Schaber <schabi@logix-tt.com>)
Responses Re: Building a database from a flat file  (Markus Schaber <schabi@logix-tt.com>)
Re: Building a database from a flat file  (Bricklen Anderson <BAnderson@PresiNET.com>)
Re: Building a database from a flat file  (Sean Davis <sdavis2@mail.nih.gov>)
List pgsql-sql
On Thu, 2005-03-03 at 08:28 -0700, Markus Schaber wrote:
> - Create the new date in another schema, and then simply rename those
> two schemas for "switch over"
> 

This worked very well.  I created another schema ("build") and populated
the tables within build.  Then:

BEGIN;
ALTER SCHEMA public RENAME TO public_old;
ALTER SCHEMA build RENAME TO public;
COMMIT;
/* remove data from tables in build schema... */

It was very quick and seamless.

Question: is there an "easy" way to duplicate an existing schema
(tables, functions, sequences, etc.)--not the data; only the schema?
This way, I would only need to modify one schema (public) to make
changes, and the build schema could be created each time as a duplicate
of the public schema.  Maintenance would be much simpler.

> - Create the new data in differently named tables, and then simply
> rename all the old and new tables for "switch over".
> 

This probably would work too, but there may be problems with foreign
keys in renaming the tables one at a time (unless deferrable is used).
To avoid any mess, the previous one works well.

> - Have two different set of tables (maybe two identical schemas), and
> let your application work on a set of views. Then you can change the
> views via "create or replace view" for switch over.
> 
> Markus

Casey



pgsql-sql by date:

Previous
From: "Casey T. Deccio"
Date:
Subject: Re: Building a database from a flat file
Next
From: Markus Schaber
Date:
Subject: Re: Building a database from a flat file