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 4944C52A6A for ; Thu, 3 Mar 2005 19:30:33 +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 72532-03 for ; Thu, 3 Mar 2005 19:30:29 +0000 (GMT) Received: from mx5.net.nih.gov (mailfwd.nih.gov [165.112.130.36]) by svr1.postgresql.org (Postfix) with ESMTP id 0E8A252A5B for ; Thu, 3 Mar 2005 19:30:28 +0000 (GMT) Received: from mx5.net.nih.gov (localhost [127.0.0.1]) by mx5.net.nih.gov (8.12.10/8.11.6) with ESMTP id j23JUSC7027064 for ; Thu, 3 Mar 2005 14:30:28 -0500 Received: from [128.231.145.14] (holmes.nhgri.nih.gov [128.231.145.14]) by mx5.net.nih.gov (8.12.10/8.11.6) with ESMTP id j23JUR8Y027036; Thu, 3 Mar 2005 14:30:27 -0500 In-Reply-To: <1109875028.12428.98.camel@boomerang.ran.sandia.gov> References: <1109808921.12430.75.camel@boomerang.ran.sandia.gov> <42272D27.4030900@logix-tt.com> <1109875028.12428.98.camel@boomerang.ran.sandia.gov> Mime-Version: 1.0 (Apple Message framework v619.2) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <659c8c4acbee32e7334c8ff68c97dcba@mail.nih.gov> Content-Transfer-Encoding: 7bit Cc: "Markus Schaber" , pgsql-sql@postgresql.org From: Sean Davis Subject: Re: Building a database from a flat file Date: Thu, 3 Mar 2005 14:30:27 -0500 To: "Casey T. Deccio" X-Mailer: Apple Mail (2.619.2) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/52 X-Sequence-Number: 20531 On Mar 3, 2005, at 1:37 PM, Casey T. Deccio wrote: > 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. Why not just create a dump of your schema (without data), drop the schema, rebuild it from the dump and then populate as normal. Then do the name switch. Sean