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 8EBCA53613 for ; Fri, 13 May 2005 16:55:51 -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 10274-06 for ; Fri, 13 May 2005 19:55:45 +0000 (GMT) Received: from werhmsg.werh.noaa.gov (werhmsg.werh.noaa.gov [198.206.32.236]) by svr1.postgresql.org (Postfix) with ESMTP id 8FE1C536AD for ; Fri, 13 May 2005 16:55:43 -0300 (ADT) Received: from [198.206.42.50] ([198.206.42.50]) by werhmsg.werh.noaa.gov (Netscape Messaging Server 4.15) with ESMTP id IGG20X00.D4A; Fri, 13 May 2005 15:55:45 -0400 Message-ID: <42850640.9090309@noaa.gov> Date: Fri, 13 May 2005 15:55:44 -0400 From: "Mark Fenbers" Organization: DoC/NOAA/NWS/OHRFC User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Ing. Jhon Carrillo" Cc: pgsql-sql@postgresql.org Subject: Re: Replacing a table with constraints References: <4284F421.10809@noaa.gov> <01c301c557ec$9983b090$1400a8c0@tgusta2> In-Reply-To: <01c301c557ec$9983b090$1400a8c0@tgusta2> Content-Type: multipart/mixed; boundary="------------060608000603070007090408" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.114 tagged_above=0 required=5 tests=AWL, HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/100 X-Sequence-Number: 21413 This is a multi-part message in MIME format. --------------060608000603070007090408 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit True, but Counties has about 8 or 9 rules, view, or pk constraints attached to it.  I don't want to break all these unless I knew of a way to save off the SQL for them beforehand so I can easily rebuild them...
Mark

Ing. Jhon Carrillo wrote:
Use          Drop table YOUR_TABLE cascade
 
Jhon Carrillo
Ingeniero en Computación
Caracas - Venezuela
 
 
----- Original Message -----
Sent: Friday, May 13, 2005 2:38 PM
Subject: [SQL] Replacing a table with constraints

I have a table called Counties which partially contains a lot bad data.  By" bad data", I mean some records are missing; some exist and shouldn't; and some records have fields with erroneous information.  However, the majority of the data in the table is accurate.  I have built/loaded a new table called newCounties with the same structure as Counties, but contains no bad data.  My was  to completely replace the contents of Counties with the contents of newCounties.  The problem is: several other tables have Foreign Key constraints placed on Counties.  Therefore, Pg will not let me 'DELETE FROM Counties;", nor will it let me "DROP TABLE Counties;" 

I'm perplexed.  Can someone suggest how I can best get data from Counties to look just like newCounties?

Mark



---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
--------------060608000603070007090408 Content-Type: text/x-vcard; charset=utf-8; name="Mark.Fenbers.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Mark.Fenbers.vcf" begin:vcard fn:Mark Fenbers n:Fenbers;Mark org:DoC/NOAA/NWS/OHRFC adr:;;1901 South SR 134;Wilmington;OH;45177-9708;USA email;internet:Mark.Fenbers@noaa.gov title:Sr. HAS Meteorologist tel;work:937-383-0430 x246 x-mozilla-html:TRUE url:http://weather.gov/ohrfc version:2.1 end:vcard --------------060608000603070007090408--