Re: May I have an assistance on CREATE TABLE Command - Mailing list pgsql-sql

From Richard Huxton
Subject Re: May I have an assistance on CREATE TABLE Command
Date
Msg-id 48D0CB74.3060407@archonet.com
Whole thread Raw
In response to Re: May I have an assistance on CREATE TABLE Command  (James Kitambara <jameskitambara@yahoo.co.uk>)
List 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


pgsql-sql by date:

Previous
From: James Kitambara
Date:
Subject: Re: May I have an assistance on CREATE TABLE Command
Next
From: "Bart Degryse"
Date:
Subject: Re: May I have an assistance on CREATE TABLE Command