zoukankan      html  css  js  c++  java
  • SQL server ——触发器

    触发器

    一个特殊的存储过程,无法直接调用,而是通过增删改的动作来触发,一个表的一个动作只能有一个触发器

    create table users

    (

    ids int primary key identity(1,1),

    name nvarchar(10),

    class nvarchar(10),

    )

    create table class

    (

    class_code nvarchar(10) primary key,

    class_name nvarchar(10),

    )

    delete from users where ids=1

    方法1:

    create trigger user_delete ——针对哪一个表的哪一个动作

    on users ——针对哪一个表的触发器

    for delete ——针对哪一个动作之后的触发器

    as    

    select * from users ——针对哪一个动作之后执行替换

    方法2:

    create trigger users1_delete

    on users

    instead of delete

    as

    select * from users

    select * from deleted

    declare @a nvarchar(10);

    select @a=ids from deleted;

    if @a>5

    begin

    select '太丑了,删不了'

    end

    else

    begin

    delete from users where ids=@a

    end

  • 相关阅读:
    Python-Re正则表达式库
    杂记
    Python 信息提取-beautifulsoup实例
    Python 中国大学排名定向爬虫
    matlab-汉字unicode编码转换
    Python-beautifulsoup库
    python 安装resquest
    python--数字灯管
    Python time库
    Python random库
  • 原文地址:https://www.cnblogs.com/weiyu11/p/6559534.html
Copyright © 2011-2022 走看看