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

From Markus Schaber
Subject Re: Building a database from a flat file
Date
Msg-id 42275B20.6030108@logix-tt.com
Whole thread Raw
In response to Re: Building a database from a flat file  ("Casey T. Deccio" <ctdecci@sandia.gov>)
List pgsql-sql
Hi, Casey,

Casey T. Deccio schrieb:

> 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.

I do not know about schemas, but for tables you can "CREATE TABLE alpha
(LIKE beta)".

>>- 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.

AFAIK, the foreign key relations are adopted when a table is renamed,
they stick to the same table disregarding name changes.


Markus
-- 
Markus Schaber | Dipl. Informatiker | Software Development GIS

Fight against software patents in EU! http://ffii.org/
http://nosoftwarepatents.org/


pgsql-sql by date:

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