首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

SQL server的触发器中after跟for的区别

2012-11-03 
SQL server的触发器中after和for的区别after delete/insert和 for delete/insert的区别[解决办法]AFTERSpe

SQL server的触发器中after和for的区别
after delete/insert和 for delete/insert的区别


[解决办法]
AFTER 
Specifies that the DML trigger is fired only when all operations specified in the triggering SQL statement have executed successfully. All referential cascade actions and constraint checks also must succeed before this trigger fires.

AFTER is the default when FOR is the only keyword specified.

AFTER triggers cannot be defined on views. 

INSTEAD OF 
Specifies that the DML trigger is executed instead of the triggering SQL statement, therefore, overriding the actions of the triggering statements. INSTEAD OF cannot be specified for DDL triggers.

At most, one INSTEAD OF trigger per INSERT, UPDATE, or DELETE statement can be defined on a table or view. However, you can define views on views where each view has its own INSTEAD OF trigger. 

INSTEAD OF triggers are not allowed on updatable views that use WITH CHECK OPTION. SQL Server raises an error when an INSTEAD OF trigger is added to an updatable view WITH CHECK OPTION specified. The user must remove that option by using ALTER VIEW before defining the INSTEAD OF trigger. 


[解决办法]

引用楼主 mcxhh2005 的帖子:
after delete/insert和 for delete/insert的区别

[解决办法]
after显然是更改后呀
for是为了嘛

热点排行