Skip to content
Advertisement

reference primary key from another table [closed]

I have to create 2 tables. the first one

and when creating the second one I got this error ORA-02270: no matching unique or primary key for this column-list

not sure what I’m doing wrong

please help

Advertisement

Answer

You need to reference a UNIQUE or PRIMARY KEY column. The payment_id column does not have one of those constraints on it.

From the Oracle constraint documentation:

Foreign Key Constraints

A foreign key constraint (also called a referential integrity constraint) designates a column as the foreign key and establishes a relationship between that foreign key and a specified primary or unique key, called the referenced key.

Instead, you can add an order_id column to your table:

db<>fiddle here

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