pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mlw <markw@mohawksoft.com>
To: pgsql-sql@postgresql.org
Subject: Re: Removing a constraint?
Date: Wed, 03 Jan 2001 11:43:20 -0500
Message-ID: <3A5356A8.2568E6F6@mohawksoft.com> (raw)
References: <01C07414.F08156B0.mdavis@sevainc.com>

Michael Davis wrote:

> Does anyone know how to completely and accurately remove or drop a
> constraint, specifically a foreign key constraint?  I tried to remove a
> constraint by deleting it's trigger from pg_triggers.  This caused some
> undesirable side effects with other tables involved with the constraint.  I
> have several tables that I need to change the column constraints and
> foreign key constraints on.  Recreating (drop and create) the table every
> time I need to change a column constraint is a pain because all the objects
> that reference the table would also need to be recreated (i.e. views and
> triggers).  How do production DBAs successfully make changes to their
> tables?
>
> FYI, I was able to alter table add the same constraint many times.  Is this
> a problem?  This created a new trigger in pg_triggers every time.

A bug in "cluster" will do this, if you cluster a table it will drop all
constraints and indexes.

One could use pg_dump, as:

pg_dump -a -t table database > table_data.sql
pg_dump -s -t table database >  table_schema.sql

(edit table_schema.sql to remove constraint)

psql database < table_schema.sql
psql database < table_data.sql








view thread (3+ messages)

Message-ID: <3A5356A8.2568E6F6@mohawksoft.com>
Permalink:  ../3A5356A8.2568E6F6@mohawksoft.com/
Also on:    postgresql.org/message-id/3A5356A8.2568E6F6@mohawksoft.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: markw@mohawksoft.com
  Subject: Re: Removing a constraint?
  In-Reply-To: <3A5356A8.2568E6F6@mohawksoft.com>
  References: <01C07414.F08156B0.mdavis@sevainc.com> <3A5356A8.2568E6F6@mohawksoft.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