Re: [SQL] How to overwrite a table [only data]?

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: Ezequias Rodrigues da Rocha <ezequias(dot)rocha(at)gmail(dot)com>
Cc: pgAdmin Support <pgadmin-support(at)postgresql(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] How to overwrite a table [only data]?
Date: 2006-10-04 16:49:21
Message-ID: 4523E611.2090704@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support pgsql-sql

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

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message Dave Page 2006-10-04 20:59:10 pgAdmin III v1.6 Beta 2 Released
Previous Message Dave Page 2006-10-04 15:13:27 Re: pgAdmin III v1.6 Beta 1 - Pg-8.2beta1: Grid editor problem

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Schaber 2006-10-04 16:52:21 Re: Assigning a timestamp without timezone to a timestamp
Previous Message Daryl Richter 2006-10-04 16:37:57 Re: i have table