Correct Syntax for alter table ..add constraint

Поиск
Список
Период
Сортировка
От Najm Hashmi
Тема Correct Syntax for alter table ..add constraint
Дата
Msg-id 3A69DDA0.610029E6@mondo-live.com
обсуждение исходный текст
Ответы Re: Correct Syntax for alter table ..add constraint
Список 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.



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

Предыдущее
От: "Tony Mantana"
Дата:
Сообщение: (No Subject)
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: Correct Syntax for alter table ..add constraint