ORA-00907: 使用 FK 时缺少右括号
ORA-00907: missing right parenthesis when using FK
SQL>
SQL> CREATE TABLE Recipe
(Quantity_used DECIMAL (2,1)
FOREIGN KEY "ICECREAM_ID"
REFERENCES icecreamGT(Icecream_id),
FOREIGN KEY (ingredient_id) REFERENCES ingredient (Ingredient_name),
);
2 3 4 5 6 FOREIGN KEY "ICECREAM_ID"
*
ERROR at line 3:
ORA-00907: missing right parenthesis
更新:新代码调整了逗号和括号
CREATE TABLE Recipe
(
Quantity_used DECIMAL (2,1),
FOREIGN KEY (ID_icecream)
REFERENCES icecreamGT(Icecream_id)
FOREIGN KEY (ID_ingredient)
REFERENCES ingredient(Ingredient_name)
);
您的声明没有:
recipe
中的 icecream_id
列 table;
recipe
中的 ingredient_id
列 table;
- 正确位置的逗号;
()
外键列列表中 "ICECREAM_ID"
标识符两边的括号。
即:
CREATE TABLE Recipe(
Quantity_used DECIMAL (2,1),
icecream_id NUMBER,
ingredient_id NUMBER,
FOREIGN KEY (ICECREAM_ID) REFERENCES icecreamGT(Icecream_id),
FOREIGN KEY (ingredient_id) REFERENCES ingredient (Ingredient_name)
);
db<>fiddle here
SQL>
SQL> CREATE TABLE Recipe
(Quantity_used DECIMAL (2,1)
FOREIGN KEY "ICECREAM_ID"
REFERENCES icecreamGT(Icecream_id),
FOREIGN KEY (ingredient_id) REFERENCES ingredient (Ingredient_name),
);
2 3 4 5 6 FOREIGN KEY "ICECREAM_ID"
*
ERROR at line 3:
ORA-00907: missing right parenthesis
更新:新代码调整了逗号和括号
CREATE TABLE Recipe
(
Quantity_used DECIMAL (2,1),
FOREIGN KEY (ID_icecream)
REFERENCES icecreamGT(Icecream_id)
FOREIGN KEY (ID_ingredient)
REFERENCES ingredient(Ingredient_name)
);
您的声明没有:
recipe
中的icecream_id
列 table;recipe
中的ingredient_id
列 table;- 正确位置的逗号;
()
外键列列表中"ICECREAM_ID"
标识符两边的括号。
即:
CREATE TABLE Recipe(
Quantity_used DECIMAL (2,1),
icecream_id NUMBER,
ingredient_id NUMBER,
FOREIGN KEY (ICECREAM_ID) REFERENCES icecreamGT(Icecream_id),
FOREIGN KEY (ingredient_id) REFERENCES ingredient (Ingredient_name)
);
db<>fiddle here