Re: Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found
Дата
Msg-id 15377.1060267299@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found  (Jason Hihn <jhihn@paytimepayroll.com>)
Ответы Re: Creating a table: UNIQUE constraint matching given keys  (Jason Hihn <jhihn@paytimepayroll.com>)
Список pgsql-novice
Jason Hihn <jhihn@paytimepayroll.com> writes:
> create table xy( x integer not null, y integer not null, primary key (x,y));
> create table xyz( x integer not null references xy(x), y integer not null
> references xy(y), z integer not null, primary key (x,y,z));
> ERROR:  UNIQUE constraint matching given keys for referenced table "xy" not
> found

I think what you want is a two-column foreign key reference:

create table xyz( x integer not null, y integer not null, z integer not null,
primary key (x,y,z),
foreign key (x,y) references xy(x,y));

            regards, tom lane

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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Creating a table: UNIQUE constraint matching given keys for referenced table "xy" not found
Следующее
От: Jason Hihn
Дата:
Сообщение: Re: Creating a table: UNIQUE constraint matching given keys