sql - 如何解决 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
)
解决方案
一张桌子的工作示例。请在 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)
)
推荐阅读
- php - Webhook 上的 Laravel 身份验证用户
- python - 如何对负整数输入执行数字求和,直到获得单个数字?
- flutter - 应用程序无错误关闭或无提示地堆栈跟踪
- mysql - MYSQL查询优化题使用Count和2个表
- javascript - 检测 Chrome 和 Edge Chromium 在我的网站上不起作用
- reactjs - 反应 event.target 设置状态。设置列表项背景颜色
- excel - 问:如何以横向格式打印 EXCEL / VBA 用户表单?
- spring-boot - 这些 Google 登录方法有什么区别?
- react-native - 使用 axios 在本机反应中发送文件时出现网络错误
- ruby-on-rails-5 - ROR - 尝试使用嵌套表单创建对象