我有另一个名为Users的表,当我在这里执行此代码时:
create table Borrow(
bookID int,
memberID int,
dayOfBorrowed date not null,
dayToReturn date not null,
giverUser int not null,
CONSTRAINT check_dayToReturn check(dayToReturn>dayOfBorrowed),
primary key (bookID, memberID),
foreign key (bookID) references Books(bookID) on delete cascade,
foreign key (memberID) references Members(memberID) on delete cascade,
foreign key (giverUser) references Users(userID) on update no action on delete no action);
我收到此错误
> Error starting at line : 72 in command - create table Borrow( bookID
> int, memberID int, dayOfBorrowed date not null, dayToReturn date not
> null, giverUser int not null, CONSTRAINT check_dayToReturn
> check(dayToReturn>dayOfBorrowed), primary key (bookID, memberID),
> foreign key (bookID) references Books(bookID) on delete cascade,
> foreign key (memberID) references Members(memberID) on delete cascade,
> foreign key (giverUser) references Users(userID) on update no action on delete no action)
> Error report - ORA-00905: missing keyword
> 00905. 00000 - "missing keyword"
> *Cause:
> *Action:
有人可以向我解释我在这里做错了吗?
答案 0 :(得分:2)
我们doc:
REFERENCES [ schema. ] object [ (column [, column ]...) ]
[ON DELETE { CASCADE | SET NULL } ]
换句话说,Oracle没有ON UPDATE
功能,因此甚至不需要ON UPDATE NO ACTION
。
P.S。您可能希望找到一个内置SQL解析的工具:
答案 1 :(得分:0)
on update
没有foreign key references
选项。
问题源于此引用(最后)行。
删除
on update no action on delete no action
一部分。
您可以使用on delete cascade
或on delete set null
,但不能使用on delete no action
条款。