了解Oracle中的DELETE NO ACTION

时间:2015-09-23 07:38:43

标签: sql oracle referential-integrity

我在表String[][] level = { {"g", "r", "g"}, {" ", "x", "t"}, //... }; for (int y = 0; y < level[0].length; y++) { for (int x = 0; x < level.length; x++) { if (level[x][y].equals("g")) draw(groundTile, x * tilewidth, y * tileheight); else if (level[x][y].equals("x")) draw(otherTile, x * tilewidth, y * tileheight); } } SRS_INST_CODE之间有一个参照完整性约束。我使用以下查询找到了SRS_INSTRUMENT规则:

ON DELETE

输出结果为:

 SELECT a.table_name, c.delete_rule, c_pk.table_name parent_table
 FROM all_cons_columns a, 
 all_constraints c,
 all_constraints c_pk
 WHERE  a.owner = c.owner
 AND a.constraint_name = c.constraint_name
 AND c.r_owner = c_pk.owner
 AND c.r_constraint_name = c_pk.constraint_name
 AND c.constraint_type = 'R'
 AND a.table_name = 'SRS_INST_CODE';

但是,即使SRS_INST_CODE NO ACTION SRS_INSTRUMENT 中有关于已删除记录的记录,我也可以从SRS_INSTRUMENT删除。此外,SRS_INST_CODE中的记录也会被删除。我希望SRS_INST_CODE而不是ON DELETE CASCADE就是这种情况。我错过了什么?

1 个答案:

答案 0 :(得分:1)

如果您通过简单的DELETE DML查询删除记录,
那么这种行为的最可能原因是在SRS_INSTRUMENT上触发,从SRS_INST_CODE中删除相应的记录 您可以通过以下查询来检查:

SELECT * FROM user_triggers WHERE table_name = 'SRS_INSTRUMENT';