Error "ORA-00907: missing right parenthesis" when specifying a foreign key for many-to-many communication
CREATE TABLE Recipe (
IDRecipe INT NOT NULL,
IDIngredient INT NOT NULL FOREIGN KEY REFERENCES Ingredients (IDIngredient),
IDDish INT NOT NULL FOREIGN KEY REFERENCES Menu (IDDish));
Constantly outputs an error:
ORA-00907: missing right parenthesis
How can I fix it? I can't figure out what's going on.
0
1 answers
Refer to the documentation:
When you specify a foreign key constraint inline, you need only the references_clause.
When you specify a foreign key constraint out of line, you must also specify the FOREIGN KEY keywords and one or more columns.
We blindly believe what is written there (in bold, our case is inline):
create table Ingredients (IDIngredient int primary key)
/
Table INGREDIENTS created.
create table Menu (IDDish int primary key)
/
Table MENU created.
create table Recipe (
IDRecipe int not null,
IDIngredient int not null references Ingredients (IDIngredient),
IDDish int not null references Menu (IDDish))
/
Table RECIPE created.
3
Author: 0xdb, 2020-09-09 18:34:35