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 E9E40563FB for ; Mon, 14 Mar 2005 02:50:36 +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 37647-05 for ; Mon, 14 Mar 2005 02:50:35 +0000 (GMT) Received: from mx5.net.nih.gov (mx5.net.nih.gov [165.112.130.36]) by svr1.postgresql.org (Postfix) with ESMTP id A6246563F9 for ; Mon, 14 Mar 2005 02:50:33 +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 j2E2obC7023170 for ; Sun, 13 Mar 2005 21:50:37 -0500 Received: from WATSON (vpn-165-112-10-36.net.nih.gov [165.112.10.36]) by mx5.net.nih.gov (8.12.10/8.11.6) with SMTP id j2E2oW8Z023157; Sun, 13 Mar 2005 21:50:37 -0500 Message-ID: <003201c52840$97206db0$1f6df345@WATSON> From: "Sean Davis" To: , References: <1mmif8pua8zxb.q7qw4hme6jk5.dlg@40tude.net> Subject: Re: Newbie wonder... Date: Sun, 13 Mar 2005 21:50:32 -0500 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.16 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/182 X-Sequence-Number: 20661 Bernard, If you are simply doing a one-time convert of an old database schema to a new one, simply load the old tables into postgres and then use SQL commands to insert the data into the new tables. For a sequence on the "existing table," you can do as above and load the old table or just use copy with the column names of all columns except the column with the serial values--these will be auto-incremented. Sean ----- Original Message ----- From: "Bernard Grosperrin" To: Sent: Tuesday, March 08, 2005 6:25 PM Subject: [SQL] Newbie wonder... > Please, bear with me, as this is my first post here. > > (1) I have a 2 table database, result of a conversion from Access. This > has > been made by an amateur, as one of the tables should be at least 3 related > tables, bunch of redundant data,and the other one 2. > > I know I could create a table as the result of a request, so that I could > isolate these redundant data, but what I don't know is how I would in the > same time update the original table to put the ID of the matching ROW > number in the newly created table, instead of the redundant data ? > > Should I create a stored procedure for that, and if yes, how ? Or should I > do that in 2 passes, sequentially ? > > (2) How should I go to create a sequence for an existing table? For all > futures data entry, after this conversion, I want the unique ID for each > row to come from a sequence, but if I know how to create a table using > serial, I am not sure how to modify one for this. > > Thanks, > Bernard > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org >