Re: Reference integrity question

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Evgen Potemkin <evgent(at)ns(dot)terminal(dot)ru>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Reference integrity question
Date: 2003-01-02 09:42:58
Message-ID: 20030102013805.A87429-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Fri, 27 Dec 2002, Evgen Potemkin wrote:

> Good time of day!
>
> I have two tables
> news(newsid int4, newscltid int4 references clt(cltid) match full,newstext text)
> and
> clt(cltid int4, somedata text).
> after clt is renamed , for ex. to clt_old, newscltid start to reference to clt_old.cltid.
> i'm create new table clt(cltid int4, anotherdata text);
>
> is there any way to make newscltid reference to newly created clt, beside
> recreation of news ?

If you mean that all newscltids should reference the new table (presumably
already loaded)...

Since you haven't given a version, let's guess 7.3, in which case the
constraint should probably be named "$1" and you can do an
ALTER TABLE news drop constraint "$1";
ALTER TABLE news add foreign key (newscltid) references clt(cltid) match
full;

but it's tougher in older versions.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Pedro Igor 2003-01-02 13:16:39 PostgreSQL X Resin EE
Previous Message Tom Lane 2003-01-02 06:16:23 Re: bug?