X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EB35452AAD for ; Thu, 3 Mar 2005 18:38:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59078-03 for ; Thu, 3 Mar 2005 18:38:45 +0000 (GMT) Received: from mm02snlnto.son.sandia.gov (mm02snlnto.sandia.gov [132.175.109.21]) by svr1.postgresql.org (Postfix) with ESMTP id DDF2856382 for ; Thu, 3 Mar 2005 18:38:44 +0000 (GMT) Received: from 132.175.109.4 by mm02snlnto.son.sandia.gov with ESMTP ( Tumbleweed MMS SMTP Relay 01 (MMS v5.6.3)); Thu, 03 Mar 2005 11:38:38 -0700 X-Server-Uuid: 914ACFB1-8EBC-470E-882B-54A00EED9786 Received: from ES22SNLNT.srn.sandia.gov (ec03snlnt.sandia.gov [134.253.164.158] (may be forged)) by mailgate2.sandia.gov ( 8.12.11/8.12.11) with ESMTP id j23IcapQ015437; Thu, 3 Mar 2005 11:38:36 -0700 (MST) Received: from 134.252.13.164 ([134.252.13.164]) by ES22SNLNT.srn.sandia.gov ([134.253.164.160]) with Microsoft Exchange Server HTTP-DAV ; Thu, 3 Mar 2005 18:38:36 +0000 Received: from boomerang by ES22SNLNT.srn.sandia.gov; 03 Mar 2005 18:37: 08 +0000 Subject: Re: Building a database from a flat file From: "Casey T. Deccio" To: "Markus Schaber" Cc: pgsql-sql@postgresql.org In-Reply-To: <42272D27.4030900@logix-tt.com> References: <1109808921.12430.75.camel@boomerang.ran.sandia.gov> <42272D27.4030900@logix-tt.com> Organization: Sandia National Laboratories Date: Thu, 03 Mar 2005 10:37:08 -0800 Message-ID: <1109875028.12428.98.camel@boomerang.ran.sandia.gov> MIME-Version: 1.0 X-Mailer: Evolution 2.0.3 X-PMX-Version: 4.7.0.111621, Antispam-Engine: 2.0.1.0, Antispam-Data: 2005.3.3.9 X-WSS-ID: 6E3986241JG1196348-01-01 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.44 tagged_above=0 required=5 tests=AWL, RCVD_NUMERIC_HELO X-Spam-Level: * X-Archive-Number: 200503/49 X-Sequence-Number: 20528 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