You have to use the separate-constraint FK syntax: CREATE TABLE words_payments ( sid text NOT NULL, social integer NOT NULL ... , foreign key (sid, social) references words_social ); Or in even more pedantic detail: foreign key (sid, social) references words_social (sid, social) You'd have to use that if (sid, social) were not the PK of words_social but just some random unique key.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных