Ошибка "ORA-00907: missing right parenthesis" при указании внешнего ключа для связи многие-ко-многим
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));
Постоянно выводит ошибку:
ORA-00907: missing right parenthesis
Как ее исправить? Не могу понять, в чём дело.
Ответы (1 шт):
Автор решения: 0xdb
→ Ссылка
Обратимся к документации:
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.
Слепо верим тому, что там написано (выделено жирным, наш случай 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.