From: Joseph Shraibman <jks@selectacast.net>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: FOREIGN KEY errors.
Date: Thu, 07 Dec 2000 23:23:07 -0500
Message-ID: <3A30622B.468EB383@selectacast.net> (raw)
When trying to alter a table and add a foreign key, I am getting this
error if the table has any data in it:
playpen=# alter table message add FOREIGN KEY (pod,originator)
REFERENCES usertable (podkey,userkey);
NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s)
for FOREIGN KEY check(s)
ERROR: constraint <unnamed>: table usertable does not have an attribute
originator
If I do the alter before I put any data in the table:
playpen=# alter table message add FOREIGN KEY (pod,originator)
REFERENCES usertable (podkey,userkey);
NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s)
for FOREIGN KEY check(s)
CREATE
playpen=# select version();
version
---------------------------------------------------------------------
PostgreSQL 7.0.3 on i686-pc-linux-gnu, compiled by gcc egcs-2.91.66
(1 row)
Reversing the order creates a different message:
playpen=# alter table message add FOREIGN KEY (originator,pod)
REFERENCES usertable (userkey,podkey);
NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s)
for FOREIGN KEY check(s)
ERROR: constraint <unnamed>: table usertable does not have an attribute
pod
Am I just misunderstanding how to use FOREIGN KEY? Then why would it
work one time and not the other?
http://www.postgresql.org/docs/aw_pgsql_book/node159.html doesn't have
any column names after 'refrences <tablename>'.
--
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio. http://www.targabot.com
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: jks@selectacast.net
Subject: Re: FOREIGN KEY errors.
In-Reply-To: <3A30622B.468EB383@selectacast.net>
References: <3A30622B.468EB383@selectacast.net>
* 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