Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4DD1A9FA27F; Wed, 4 Oct 2006 13:49:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 05282-02; Wed, 4 Oct 2006 13:49:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 5000E9FB1EE; Wed, 4 Oct 2006 13:49:23 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (p549D1602.dip0.t-ipconnect.de [84.157.22.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 92C8E65997; Wed, 4 Oct 2006 18:51:48 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id AEFEC18818CDE; Wed, 4 Oct 2006 18:49:21 +0200 (CEST) Message-ID: <4523E611.2090704@logix-tt.com> Date: Wed, 04 Oct 2006 18:49:21 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Thunderbird 1.5.0.5 (X11/20060812) MIME-Version: 1.0 To: Ezequias Rodrigues da Rocha Cc: pgAdmin Support , pgsql-sql@postgresql.org Subject: Re: [SQL] How to overwrite a table [only data]? References: <55c095e90610040440v431e15a3m34fa72ef19c239e8@mail.gmail.com> In-Reply-To: <55c095e90610040440v431e15a3m34fa72ef19c239e8@mail.gmail.com> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.203 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200610/16 X-Sequence-Number: 5853 Hi, Ezequias, Ezequias Rodrigues da Rocha wrote: > I would like to overwrite a table with problem with his original. But > there are some points. > > I can't just delete and restore it becouse it has a foreign key and > when I try to delete it ask for drop cascade. As long as the delete and restore is in the same transaction, SET CONSTRAINTS ALL DEFERRED might help. See the docs for more info. > As I know the drop cascade delete in both tables the rows related. Is > it correct ? Yes, cascade will delete all referencing rows in the otehr table to keep the constraints intact, keeping only those rows that have NULL in the foreign key. I think that's not exactly what you want. HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in Europe! www.ffii.org www.nosoftwarepatents.org