Skip to content
Advertisement

postgresql: relation “table_name” does not exist when trying to CREATE TABLE

I am running this code thru pgAdmin4:

i am keep getting this message: ERROR: relation “supplier” does not exist SQL state: 42P01

The problem is with the foreign key in the product table (1st table), i know this because i removed it and it created all the tables with values (i removed some of the values to facilitate the writing).

Not sure if its a syntax error, i tried a couple of ways to solve it but i am clueless, any suggestions? Thanks in advance.

Advertisement

Answer

You have to create supplier table before product table as sid from product table references to sid in supplier table as a foreign key.

Here is the working demo.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement