Postgres add foreign key

broken image
broken image

These are the data definitions for my two test tables.

broken image

Make sure that the table columns chosen as primary or foreign key do not accept NULL values by making them mandatory. SQL Error : No matching key defined for the referenced table (7545)Ĭolumns defining a primary or foreign key must not accept the NULL value. I do it in the Dbeaver. But I got the following error: I am trying to add a foreign key to my existing table using by SQL command.ĪLTER TABLE PUB.'Order' ADD CONSTRAINT ORDER_CUSTOMER_FK FOREIGN KEY ('Cust_Num') REFERENCES PUB.'Customer'('Cust_Num')

broken image