触发器详解

今天偶尔用到了触发器,之前并没有怎么用过,没想到这个东东是这么的好使,于是总结了几点,作为以后的参考:
        基本语法:
               create trigger 〔触发器名称〕
               on 〔触发器所在的表〕
               for INSERT, UPDATE, DELETE (应用的条件)
               as
               begin
               update ceshi set zs=zs+1  (需要触发的事件)
               end

        例:
        create trigger updateceshi
        on ceshi2
        for update
        as
        begin
        update ceshi set zs=zs+1
        end
        在ceshi2表上建立名称为:updateceshi  的触发器,当ceshi2 表 update 时,ceshi 表的 zs 字段自加 1 ;

posted on 2007-01-19 09:12  Sunlight  阅读(551)  评论(0编辑  收藏  举报

导航