甲骨文中的触发器 [英] Triggers in oracle

查看:111
本文介绍了甲骨文中的触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

触发器可以增强或阻碍性能的条件是什么?何时使用和何时不使用系统中的触发器?

What are the condtions where triggers can enhance or hinder the performance? When to use and when not to use the triggers in the system?

如何使用触发器来施加复杂的约束?

How triggers can be used to impose complex constraints?

推荐答案

执行触发器总是会产生一些开销-至少,对于每一行,您都要从SQL引擎到PL/SQL引擎进行上下文转换导致触发器触发.尽管触发触发器的开销的绝对大小相对恒定,但是开销的百分比因您执行DML的方式而异.如果您的应用程序正在添加或修改集合中的行,这是对关系数据进行操作的最快方法,则触发器会对性能产生更大的相对影响,因为这些上下文转换的成本加上实际使用的任何触发器的成本这样做,很快就占了触发DML的成本.

Executing a trigger always has some overhead-- at a minimum, you are doing a context shift from the SQL engine to the PL/SQL engine for every row that causes the trigger to fire. While the absolute magnitude of the overhead of firing a trigger is relatively constant, the percentage overhead is highly variable depending on how you are doing DML. If you have an application that is adding or modifying rows in sets, which is the fastest way to operate on relational data, triggers have a much larger relative impact on performance because the cost of those context shifts plus the cost of whatever the trigger is actually doing, quickly dominates the cost of doing the triggering DML.

理论上,触发器可以用于强制执行复杂的约束,因为触发器可以查询其他表或调用函数以进行复杂的比较.但是在实践中,即使不是不可能,也很难以在多用户环境中实际正确的方式对这些触发器进行编码,因此设计一个需要约束来查看数据的系统通常不是一个好主意.桌子.这通常表明数据模型存在问题.

In theory, a trigger can be used to enforce complex constraints because a trigger can query other tables or call functions to do complex comparisons. In practice, however, it is extremely difficult if not impossible to code these triggers in a way that is actually correct in a multi-user environment so it is generally not a good idea to design a system that would need constraints that look at data across tables. That generally indicates a problem with the data model.

这篇关于甲骨文中的触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆