我正在尝试创建一个表命令来创建一个关系;
create table Driver(
Driver_Licence char(15) primary key,
SSN int unique,
First_Name varchar(50) not null,
Last_Name varchar(50),
Birth_Date date DEFAULT '1900-01-01',
Hire_Date date COMMENT 'Hire_Date is the date that employee was first Hired',
State char(2),
INDEX (State),
CONSTRAINT CHK_Driver_HireDate CHECK(Hire_Date > Birth_Date)
);
但是我一直得到这个错误:
Error report -
ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
我一直想弄清楚,但是我一直找不到解决它的方法。如果你们谁能帮我,那就太好了!
我认为Oracle既不支持表中的内联注释,也不支持创建索引。这些需要单独的语句。
Oracle建议使用varchar2()
而不是varchar()
。日期文字前应加上date
:
create table Driver(
Driver_Licence char(15) primary key,
SSN int unique,
First_Name varchar2(50) not null,
Last_Name varchar2(50),
Birth_Date date DEFAULT date '1900-01-01',
Hire_Date date,
State char(2),
CONSTRAINT CHK_Driver_HireDate CHECK(Hire_Date > Birth_Date)
);
comment on column driver.hire_date is 'Hire_Date is the date that employee was first Hired';
create index idx_driver_state on driver(state);
这是一个db<>小提琴