zoukankan      html  css  js  c++  java
  • SQL SERVER 触发器示例

    触发器是一种特殊的存储过程。

    触发器语法 :

    CREATE TRIGGER trigger_name ON { table | view } [ WITH ENCRYPTION ]

    { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ DELETE ] [ UPDATE ] }

    [ WITH APPEND ] [ NOT FOR REPLICATION ]

    AS

      sql_statement [ ...n ]

    示例:
    删除:

    DROP TRIGGER auto_guid_trigger

    创建:

    CREATE TRIGGER auto_guid_trigger ON AUTO_GUID FOR UPDATE AS
      IF (SELECT COUNT(GID) FROM AUTO_GUID WHERE LOCKED=0)<1000
      BEGIN
        DECLARE @ii INT
        SET @ii=1
        WHILE @ii<=10000
        BEGIN
          INSERT INTO AUTO_GUID(LOCKED) VALUES(0)
          SET @ii=@ii+1
        END
      END

    informix触发器参考:

    http://www.blogjava.net/amigoxie/archive/2010/11/05/337363.html

  • 相关阅读:
    python re模块
    python
    python
    Django学习手册
    Django学习手册
    前端
    前端
    Django学习手册
    前端
    Database学习
  • 原文地址:https://www.cnblogs.com/zjking99/p/2108738.html
Copyright © 2011-2022 走看看