SQL Developer 17.2中出现ORA-00922错误的问题

时间:2018-12-11 21:18:23

标签: sql oracle debugging syntax syntax-error

我正在使用一个类项目的SQL编写当前代码,并收到以下错误:

  

错误报告-   ORA-00922:丢失或无效的选项   00922. 00000-“选项缺失或无效”   *原因:
  *行动:   从第1行开始出错-命令-

我的代码如下:

ActiveSheet

是什么导致我的错误?

1 个答案:

答案 0 :(得分:0)

您正在使用的工具以及该工具的使用方式将确定您是否需要';'是否在语句之间。

表的一种语法不好。

create table Vehicle(
    VehicleID number(8) primary key, 
    DriverID number(8) references Driver(DriverID), 
    VehicleAvailable varchar2(5) check(VehicleAvailable IN ('TRUE','FALSE')), -- you forgot the IN keyword
    VehicleRate number(4) not null, 
    VehicleModel varchar2(10) not null, 
    VehicleMake varchar2(10) not null, 
    DateOfRegistration date not null, 
    RegistrationNumber number(8) unique, 
    VehicleColour varchar2(10) not null
);

此外,我建议您将FK约束设置为ALTER TABLE ADD CONSTRAINT与在线约束。这样,您可以创建所有表,添加约束,而不必担心循环引用或只是在脚本中获得正确的顺序。

类似这样,但是所有更改都在脚本的末尾。

CREATE TABLE admini (
    admin_id     NUMBER(8) PRIMARY KEY,
    employeeid   NUMBER(8),
    bookingid    NUMBER(8) );

ALTER TABLE admini
    ADD CONSTRAINT admini_employeeinformation_fk FOREIGN KEY ( employeeid )
        REFERENCES employeeinformation ( employeeid )
    ENABLE;

ALTER TABLE admini
    ADD CONSTRAINT admini_booking_fk FOREIGN KEY ( bookingid )
        REFERENCES booking ( bookingid )
    ENABLE;