pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Najm Hashmi <najm@mondo-live.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Correct Syntax for alter table ..add constraint
Date: Sat, 20 Jan 2001 13:49:04 -0500
Message-ID: <3A69DDA0.610029E6@mondo-live.com> (raw)

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.




view thread (3+ messages)  latest in thread

Message-ID: <3A69DDA0.610029E6@mondo-live.com>
Permalink:  ../3A69DDA0.610029E6@mondo-live.com/
Also on:    postgresql.org/message-id/3A69DDA0.610029E6@mondo-live.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: najm@mondo-live.com
  Subject: Re: Correct Syntax for alter table ..add constraint
  In-Reply-To: <3A69DDA0.610029E6@mondo-live.com>
  References: <3A69DDA0.610029E6@mondo-live.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox