首页 > 解决方案 > 创建表时出现 sql 错误“ORA-00907:缺少右括号”

问题描述

我正在尝试创建表,但表 ROUTE 发生错误。我不知道为什么。你能指出我的问题吗?谢谢。

create table LOCATION (  
  airportCode   VARCHAR2(10) not null,  
  country       VARCHAR2(15) not null,  
  address       VARCHAR2(50) not null,  
  PRIMARY KEY(airportCode));

create table ROUTE (  
  routeID       VARCHAR2(10) not null,  
  airportCode   VARCHAR2(10) not null,  
  description   VARCHAR2(100) not null,  
  PRIMARY KEY(routeID, airportCode)
  FOREIGN KEY(airportCode) REFERENCES LOCATION(airportCode));

这个错误来了,ORA-00907:缺少右括号。所有括号均已正确放置,但仍显示此错误。

标签: sqldatabaseoraclesqlplus

解决方案


PRIMARY KEY(routeID, airportCode)和之间缺少 ,(逗号)FOREIGN KEY(airportCode)


推荐阅读