Correct Syntax for alter table ..add constraint

From: Najm Hashmi <najm(at)mondo-live(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Correct Syntax for alter table ..add constraint
Date: 2001-01-20 18:49:04
Message-ID: 3A69DDA0.610029E6@mondo-live.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi All,
What is the correct syntax for adding a foreign key constraint from the
command line.
I am using v7.1 beta3..... I am doing the follwoing:
alter table users
add constraint age_fk foreign key(age)
references age_list(id);
And I get the following error:
flipr=# alter table users
flipr-# add constraint age_fk foreign key(age) references age_list(id);
NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s)
for FOREIGN KEY check(s)
ERROR: <unnamed> referential integrity violation - key referenced from
users not found in age_list

I have define attribute id as primary key of the table.......
Thanks for your help. Regards,Najm.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Najm Hashmi 2001-01-20 19:50:00 Re: Correct Syntax for alter table ..add constraint
Previous Message Kovacs Zoltan Sandor 2001-01-20 12:19:24 Re: pl/pgSQL & transaction