如何在Oracle中使用级联 [英] how to use cascade in oracle
问题描述
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
);
该错误已在oracle中使用.
the error is come on use in oracle.
foreign key(userId) references userDetails(userId) on delete cascade on update
级联 *
cascade *
第9行出现错误: ORA-00907:右括号缺失
ERROR at line 9: ORA-00907: missing right parenthesis
此查询在mysql上有效,但在oracle中不起作用?请任何人告诉我它在oracle中是如何工作的.
This query is working on mysql but in oracle is not working? please anyone tell me how it work in oracle.
推荐答案
Oracle不支持主键的级联更新.主键应该既是唯一的又是不变的,因此永远不需要更改.由于您永远都不应更新主键,因此无需级联这些更新.
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.
通常,您可能还应该使用VARCHAR2
数据类型,而不是VARCHAR
.当前,这些数据类型是相同的,但是Oracle将来可能会更改VARCHAR
类型的语义,以使空字符串与NULL
的处理方式有所不同.假设您不希望将来的应用程序在这些语义发生更改时崩溃,那么使用VARCHAR2
会更安全.
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
.
这篇关于如何在Oracle中使用级联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!