SQL错误:ORA-00907:缺少右括号 [英] SQL Error: ORA-00907: missing right parenthesis

查看:209
本文介绍了SQL错误:ORA-00907:缺少右括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Oracle SQL Developer通过以下命令创建基本表:

I am using Oracle SQL developer to create a basic table with the following command:

CREATE TABLE chartered_flight(
   flight_no NUMBER(4) PRIMARY KEY
   , customer_id FOREIGN KEY
   , aircraft_no FOREIGN KEY
   , flight_type VARCHAR2 (12)
   , flight_date DATE NOT NULL
   , flight_time TO_DATE 'HH:MI' NOT NULL
   , takeoff_at CHAR (3) NOT NULL
   , destination CHAR (3) NOT NULL
)

缺少的右括号在哪里?还是我使用的语法不正确.

Where is the missing right parenthesis? Or is the syntax that I have used incorrect.

我进行了以下更改:

CREATE TABLE chartered flight(
   flight_no NUMBER(4) PRIMARY KEY
   , customer_id NUMBER(6) REFERENCES [customer]([customer_id])
   , aircraft_no NUMBER(4) REFERENCES [aircraft]([aircraft_no])
   , flight_type VARCHAR2 (12)
   , flight_date DATE NOT NULL
   , flight_time INTERVAL DAY TO SECOND NOT NULL
   , takeoff_at CHAR (3) NOT NULL
   , destination CHAR (3) NOT NULL)

现在我收到此错误:

Error at Command Line:1 Column:23
Error report:
SQL Error: ORA-00922: missing or invalid option
00922. 00000 -  "missing or invalid option"
*Cause:    
*Action:

我觉得这与TO_DATE有关,或者是因为我尚未创建飞机表,所以缺少aircraft_no吗?有人可以帮忙吗,谢谢.

I have a feeling it is something to do with TO_DATE or is it because I have not created my aircraft table yet so aircraft_no is missing? Can some one please help, thanks.

推荐答案

要指定外键约束,您应该使用内联customer_id [type] REFERENCES [master_table_name]([master_column_name])或外联语法:, CONSTRAINT [constraint_name] FOREIGN KEY(customer_id) REFERENCES [master_table_name]([master_column_name])查看更多示例

To specify foreign key constraint, you should either use inline customer_id [type] REFERENCES [master_table_name]([master_column_name]) or out of line syntax : , CONSTRAINT [constraint_name] FOREIGN KEY(customer_id) REFERENCES [master_table_name]([master_column_name]) See more example here. Also, it usually makes sense to add indexes on foreign key columns.

对于flight_time,您可能需要使用INTERVAL DAY TO SECOND类型

For flight_time you probably need to use INTERVAL DAY TO SECOND type

这篇关于SQL错误:ORA-00907:缺少右括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆