how to use cascade in oracle

非 Y 不嫁゛ 提交于 2019-12-11 07:08:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!