foreign key creation problem

Поиск
Список
Период
Сортировка
От Adam Fisher
Тема foreign key creation problem
Дата
Msg-id 9v9683$2pbm$1@news.tht.net
обсуждение исходный текст
Ответы Re: foreign key creation problem  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-general
Hi All,
I am trying to add a foreign key comstraint to an already-populated table
using the ALTER TABLE command. I am linking to the primary key of the master
table, and the slave table also has a primary key, however the field I am
adding the constraint to is not indexed.
When I try and create the constraint using:
alter table inventory
add constraint fk_inv_item_stkNo
foreign key ("stockNo") references "item" ("stockNo")

i get the following message:

UNIQUE constraint matching given keys for referenced table not found "item"

Can anybody tell me what I'm doing wrong? The field stockNo in the item
table is the primary key, so it is unique. Both fields have the dataType
integer and the primary key is also a sequence (i.e auto-incrementing)

thanks
adam






В списке pgsql-general по дате отправления:

Предыдущее
От: Joseph Shraibman
Дата:
Сообщение: dropping foreign keys
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: dropping foreign keys