From: Scott Marlowe <smarlowe@g2switchworks.com>
To: Mark Fenbers <Mark.Fenbers@noaa.gov>
Cc: Ing. Jhon Carrillo <jdigital@cantv.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Replacing a table with constraints
Date: Fri, 13 May 2005 15:03:51 -0500
Message-ID: <1116014631.22291.52.camel@state.g2switchworks.com> (raw)
In-Reply-To: <42850640.9090309@noaa.gov>
References: <4284F421.10809@noaa.gov>
<01c301c557ec$9983b090$1400a8c0@tgusta2>
<42850640.9090309@noaa.gov>
Are the constraints deferrable?
If they are, then you can replace the data with a single transaction.
If not, then you'll have to look at disabling triggers for the update.
On Fri, 2005-05-13 at 14:55, Mark Fenbers wrote:
> 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 -----
> > From: Mark Fenbers
> > To: pgsql-sql@postgresql.org
> > 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
>
>
> ______________________________________________________________________
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: smarlowe@g2switchworks.com, Mark.Fenbers@noaa.gov, jdigital@cantv.net
Subject: Re: Replacing a table with constraints
In-Reply-To: <1116014631.22291.52.camel@state.g2switchworks.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox