Foreign Key can't refer to one of 2 primary keys

Поиск
Список
Период
Сортировка
От Reuben D. Budiardja
Тема Foreign Key can't refer to one of 2 primary keys
Дата
Msg-id 200306211704.19123.techlist@voyager.phys.utk.edu
обсуждение исходный текст
Ответы Re: Foreign Key can't refer to one of 2 primary keys  (Gianni Mariani <gianni@mariani.ws>)
Re: Foreign Key can't refer to one of 2 primary keys  (Mark Wilson <mwilson13@cox.net>)
Список pgsql-general
Hi all,
Suppose I have a table with more than one primary key. If I create another
table and I want one of the column of that second table REFERENCE to one of
the primary key of the first table, how do I do that?

eg
CREATE TABLE test
(
col1 VARCHAR(20),
col2 VARCHAR(20),
col3 VARCHAR(20),
PRIMARY KEY (col1,col2,col3)
);

CREATE TABLE myforeign
(
mycol1 VARCHAR(20) REFERENCES test,
mycol2 VARCHAR(25),
PRIMARY KEY(mycol1)
);

This gave me

ERROR:  number of key attributes in referenced table must be equal to foreign
key
        Illegal FOREIGN KEY definition references "test"


I don't se any obvious reason why I cannot do that. Any help?

Thanks.
--
Reuben D. Budiardja


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

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: [pgsql-advocacy] Governance WAS: MySQL gets $19.5 MM
Следующее
От: Gianni Mariani
Дата:
Сообщение: Re: Foreign Key can't refer to one of 2 primary keys