首页 > 解决方案 > 如何解决 ORA-00907:缺少右括号错误?

问题描述

我无法在此代码中找到错误,它显示ORA-00907:两者都缺少右括号。我在 Oracle live SQL 上执行此操作。

CREATE table Final_chart 
( 
T_id int FOREIGN KEY REFERENCES Train(T_id), 
User_id varchar(10) FOREIGN KEY REFERENCES Passenger(User_id), 
Seat_id int FOREIGN KEY REFERENCES Train_Seats(Seat_id), 
CONSTRAINT PNR PRIMARY KEY (T_id,User_id,Seat_id)  
)

CREATE table Train_seats  
(  
T_id int FOREIGN KEY REFERENCES Train(T_id), 
Seat_id int PRIMARY KEY,  
Waiting int NOT NULL,  
Available int NOT NULL,  
Booked_seat int NOT NULL  
) 

在此处输入图像描述

标签: sqloracle

解决方案


一张桌子的工作示例。请在 oracle 的 varchar 上使用 varchar2。

CREATE table Final_chart 
(T_id integer, 
User_id varchar2(10), 
Seat_id integer,
CONSTRAINT t2_fk  FOREIGN KEY (T_id) REFERENCES Train(T_id),
CONSTRAINT t1_fk  FOREIGN KEY (User_id) REFERENCES Passenger(User_id),
CONSTRAINT t3_fk FOREIGN KEY  (Seat_id) REFERENCES Train_Seats(Seat_id),
CONSTRAINT Pkr PRIMARY KEY (T_id, User_id, Seat_id)
)

推荐阅读