X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C95ED9DCAC3 for ; Thu, 2 Mar 2006 16:28:21 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78213-03 for ; Thu, 2 Mar 2006 16:28:18 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from hotmail.com (bay102-f31.bay102.hotmail.com [64.4.61.41]) by postgresql.org (Postfix) with ESMTP id 089199DCA42 for ; Thu, 2 Mar 2006 16:28:15 -0400 (AST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 2 Mar 2006 12:28:16 -0800 Message-ID: Received: from 64.4.61.200 by by102fd.bay102.hotmail.msn.com with HTTP; Thu, 02 Mar 2006 20:28:15 GMT X-Originating-IP: [66.160.12.215] X-Originating-Email: [bitsandbytes88@hotmail.com] X-Sender: bitsandbytes88@hotmail.com From: "Mr. Dan" To: pgsql-admin@postgresql.org Subject: table manipulation Date: Thu, 02 Mar 2006 15:28:15 -0500 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 02 Mar 2006 20:28:16.0893 (UTC) FILETIME=[D677B2D0:01C63E37] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.616 required=5 tests=[AWL=-0.303, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, MSGID_FROM_MTA_HEADER=0] X-Spam-Score: 1.616 X-Spam-Level: * X-Archive-Number: 200603/26 X-Sequence-Number: 20783 I have a large database (20 Gb) on PostgreSQL 8.1.0 where I need to make a copy of the structure and also copy the data from a few of the tables (approximately 40 out of 140, resulting database is approximately 10 Mb) which have dependencies on each other. The problem I am having is finding the best way to go about this using an automated script. There were a few options I could think of: 1) copy the whole large database and then truncate the tables I didn't need (the tables I need have a specific naming scheme). This seems wasteful and can take up to 5 hours to do. 2) copy the schema from the database and then dump just the tables I want and restore them on the new database. The problem I run into here is the inter-dependencies between some of the tables makes this hard to do programmatically (I could hard code the order list of which tables to fill, but then what happens when we add more tables?) Are there other approaches that I'm missing here? I need to do this across several databases which have basically the same structures and naming schemes but the dependencies on all of the databases are different. I'm trying to come up with a generic solution that I can use for all of the databases without having to maintain the dependencies for each.