pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Correct Syntax for alter table ..add constraint
3+ messages / 2 participants
[nested] [flat]

* Re: Correct Syntax for alter table ..add constraint
@ 2001-01-19 19:30  Josh Berkus <josh@agliodbs.com>
  parent: Najm Hashmi <najm@mondo-live.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Josh Berkus @ 2001-01-19 19:30 UTC (permalink / raw)
  To: Najm Hashmi <najm@mondo-live.com>; +Cc: pgsql-sql

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:  <unnamed> 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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Correct Syntax for alter table ..add constraint
@ 2001-01-20 18:49  Najm Hashmi <najm@mondo-live.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Najm Hashmi @ 2001-01-20 18:49 UTC (permalink / raw)
  To: 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.




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Correct Syntax for alter table ..add constraint
@ 2001-01-20 19:50  Najm Hashmi <najm@mondo-live.com>
  parent: Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Najm Hashmi @ 2001-01-20 19:50 UTC (permalink / raw)
  To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql

Josh Berkus wrote:

> 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:  <unnamed> 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

HI  Josh,
All values in age column of  are null..... I have no value there......
and I have specified to accetp nulls i.e.  I dont have constraint not
null on this particular column...
Najm




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-01-20 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-20 18:49 Correct Syntax for alter table ..add constraint Najm Hashmi <najm@mondo-live.com>
2001-01-19 19:30 ` Josh Berkus <josh@agliodbs.com>
2001-01-20 19:50   ` Najm Hashmi <najm@mondo-live.com>

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