问题
create table loginDetails(
userId varchar(30),
cellPhoneNo varchar(10),
displayName varchar(20),
password varchar(20),
secretQuestion varchar(50),
secretAnswer varchar(50),
joiningDate date,
foreign key(userId) references userDetails(userId) on delete cascade on update cascade
);
the error is come on use in oracle.
foreign key(userId) references userDetails(userId) on delete cascade on update
cascade *
ERROR at line 9: ORA-00907: missing right parenthesis
This query is working on mysql but in oracle is not working? please anyone tell me how it work in oracle.
回答1:
Oracle does not support cascading updates of primary keys. The primary key ought to be both unique and immutable so it shouldn't ever need to change. Since you should never be updating a primary key, there should be no need to cascade those updates.
In general, you probably also ought to use the VARCHAR2 data type rather than VARCHAR. Currently, those data types are identical but Oracle may change the semantics of the VARCHAR type in the future to cause the empty string to be treated differently from NULL. Assuming you don't want your application to potentially break in the future when those semantics change, it would be safer to use VARCHAR2.
来源:https://stackoverflow.com/questions/11174533/how-to-use-cascade-in-oracle