Received: from lin.local.lan ([216.221.221.2]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0JIhW040438 for ; Fri, 19 Jan 2001 13:43:32 -0500 (EST) (envelope-from najm@mondo-live.com) Received: from mondo-live.com (IDENT:najm@ll20.local2.lan [192.168.2.20]) by lin.local.lan (8.9.3/8.8.7) with ESMTP id RAA09241 for ; Fri, 19 Jan 2001 17:37:44 GMT Message-ID: <3A69DDA0.610029E6@mondo-live.com> Date: Sat, 20 Jan 2001 13:49:04 -0500 From: Najm Hashmi X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 To: "pgsql-sql@postgresql.org" Subject: Correct Syntax for alter table ..add constraint Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200101/264 X-Sequence-Number: 933 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: 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.