oracle ORA-00907: 缺少右括号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6819869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:10:50  来源:igfitidea点击:

ORA-00907: missing right parenthesis

sqloracleora-00907

提问by Chandu

CREATE TABLE Persons (
  P_Id int NOT NULL,
  LastName varchar(255) NOT NULL,
  FirstName varchar(255),
  PRIMARY KEY (P_Id)
)

CREATE TABLE Orders (
  O_Id int NOT NULL PRIMARY KEY,
  OrderNo int NOT NULL,
  P_Id int FOREIGN KEY REFERENCES Persons(P_Id)
)

I am getting an error while creating Table Orders:

创建表订单时出现错误:

ORA-00907: missing right parenthesis

ORA-00907: 缺少右括号

回答by Chandu

If you are defining a foreign key inline with column definition then you shouldn't specify FOREIGN KEY. Drop it from the definition.

如果您要定义与列定义内联的外键,则不应指定 FOREIGN KEY。从定义中删除它。

Try this:

尝试这个:

CREATE TABLE Orders 
( 
  O_Id int NOT NULL PRIMARY KEY, 
  OrderNo int NOT NULL,
  P_Id int REFERENCES Persons(P_Id)
)