使用以下命令在SQL中创建表时,我收到ORA-00936:表达式错误消息。我绊倒的任何想法?
CREATE TABLE Workorders (
Wo# VARCHAR2(8) PRIMARY KEY,
Proj# VARCHAR2(8) REFERENCES Project (Proj#),
Wo_desc VARCHAR2(30) NOT NULL UNIQUE,
Wo_assigned CHAR(40),
Wo_hours NUMBER(6) NOT NULL CHECK(>0),
Wo_start DATE,
Wo_due DATE,
Wo_complete CHECK (Wo_complete IN ('Y','N')));
答案 0 :(得分:1)
您不能像这样定义检查约束,您需要检查中的列名:
CREATE TABLE Workorders (
Wo# VARCHAR2(8) PRIMARY KEY,
Proj# VARCHAR2(8) REFERENCES Project (Proj#),
Wo_desc VARCHAR2(30) NOT NULL UNIQUE,
Wo_assigned CHAR(40),
Wo_hours NUMBER(6,0) NOT NULL CHECK ( wo_hours > 0 ),
Wo_start DATE,
Wo_due DATE,
Wo_complete CHAR(1) CHECK (Wo_complete IN ('Y','N') )
);