Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0JJUD045099 for ; Fri, 19 Jan 2001 14:30:14 -0500 (EST) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.3) with HTTP id 1179538; Fri, 19 Jan 2001 11:30:12 -0800 From: "Josh Berkus" Subject: Re: Correct Syntax for alter table ..add constraint To: Najm Hashmi Cc: pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.3 Date: Fri, 19 Jan 2001 11:30:12 -0800 Message-ID: In-Reply-To: <3A69DDA0.610029E6@mondo-live.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200101/265 X-Sequence-Number: 934 Najm, > 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 Simple ... you have values in the AGE column that are not in the age_list table. Thus you're in violation of the foriegn key you're trying to establish. -Josh Berkus