Correct Syntax for alter table ..add constraint - Mailing list pgsql-sql

From Najm Hashmi
Subject Correct Syntax for alter table ..add constraint
Date
Msg-id 3A69DDA0.610029E6@mondo-live.com
Whole thread Raw
Responses Re: Correct Syntax for alter table ..add constraint
List 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.



pgsql-sql by date:

Previous
From: "Tony Mantana"
Date:
Subject: (No Subject)
Next
From: "Josh Berkus"
Date:
Subject: Re: Correct Syntax for alter table ..add constraint