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 73314D1B7C6 for ; Fri, 25 Jun 2004 06:57:52 -0300 (ADT) 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 00756-07 for ; Fri, 25 Jun 2004 09:57:53 +0000 (GMT) Received: from gatekeeper.fma.co.za (gatekeeper.fma.co.za [196.30.143.210]) by svr1.postgresql.org (Postfix) with ESMTP id 75FD8D1B175 for ; Fri, 25 Jun 2004 06:57:46 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by gatekeeper.fma.co.za (Postfix) with ESMTP id 6398033020; Fri, 25 Jun 2004 11:57:40 +0200 (SAST) Received: from gatekeeper.fma.co.za ([127.0.0.1]) by localhost (gatekeeper.fma.co.za [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23803-04; Fri, 25 Jun 2004 11:57:39 +0200 (SAST) Received: from [196.30.143.210] (gatekeeper.fma.co.za [196.30.143.210]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by gatekeeper.fma.co.za (Postfix) with ESMTP id DBF053301F; Fri, 25 Jun 2004 11:57:30 +0200 (SAST) Message-ID: <40DBF70A.6060605@sharp.fm> Date: Fri, 25 Jun 2004 11:57:30 +0200 From: Graham Leggett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040623 X-Accept-Language: en-za, en-us, en MIME-Version: 1.0 To: Richard Huxton Cc: Frank Bax , pgsql-sql@postgresql.org Subject: Re: Normalising an existing table - how? References: <5.2.1.1.0.20040624170431.04384a70@pop6.sympatico.ca> <40DB4B64.5080101@sharp.fm> <40DBE463.7060308@archonet.com> In-Reply-To: <40DBE463.7060308@archonet.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at fma.co.za X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/257 X-Sequence-Number: 18202 Richard Huxton wrote: >> How would I put the primary key of each row in newtable back into >> oldtable? Also, newtable already exists and contains data - I need to >> add normalised data to an already partially normalised database. > How can newtable contain data if you don't have any keys for it? > > Perhaps a fuller example, with the schemas of the tables in question > would help. I have a system that keeps track of money. Part of the system's money handling is already normalised, in that there is a money table, containing information about the amount concerned, the amount of tax appropriate, the currency involved, etc. Part of the system is not normalised, in that a simple column in table contains the amount of money, but not the tax appropriate, nor the currency involved. My task is to fix this situation to make it consistent throughout. Because the database is partially normalised, the money table already contains rows corresponding to the properly normalised part of the database. New rows need to be added on top of the existing rows, replacing the rest of the columns that need to be normalised. As a result, creating a new money table is not possible, as this table already exists. Regards, Graham --