Re: May I have an assistance on CREATE TABLE Command

From: Richard Huxton <dev(at)archonet(dot)com>
To: jameskitambara(at)yahoo(dot)co(dot)uk
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: May I have an assistance on CREATE TABLE Command
Date: 2008-09-17 09:18:44
Message-ID: 48D0CB74.3060407@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

James Kitambara wrote:
> For this UPDATE I wanted, when I change the region _id from '99' to
> '33' of the last ROW in REGION table AUTOMATICALLY to change the
> last three ROWS of the DISTRICT table which reference to '99', 'Dar
> es Salaam'.
>
> If I do this, I will get the error message "You can not change
> region_id other tables are reference to it.
>
> HOW CAN DO THIS? (AUTOMATIC UPDATE OF FOREIGN KEY)

When you define your foreign key mark it "ON UPDATE CASCADE" (there is a
similar option for ON DELETE). See manuals for details.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bart Degryse 2008-09-17 11:01:45 Re: May I have an assistance on CREATE TABLE Command
Previous Message James Kitambara 2008-09-17 09:13:17 Re: May I have an assistance on CREATE TABLE Command