Home > Database > Mysql Tutorial > sql触发器delete与update操作

sql触发器delete与update操作

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:49:00
Original
1125 people have browsed it

本文章讲述最简单的sql 触发器的delete和update操作,有需要学习的同学可以参考一下本文章。

编写:

 代码如下 复制代码
create trigger BlogDelet
on Blog
instead of delete
as
delete from Comment
where CommentBlog in ( Id from deleted)

创建一个Update触发器:

 代码如下 复制代码

     Create Trigger truStudent
       On Student                         --在Student表中创建触发器
       for Update                          --为什么事件触发
     As                                        --事件触发后所要做的事情
       if Update(StudentID)           
       begin

         Update BorrowRecord
           Set StudentID=i.StudentID
           From BorrowRecord br , Deleted   d ,Inserted i      --Deleted和Inserted临时表
           Where br.StudentID=d.StudentID

       end      

 

更多详细的关于sql触发器可参考

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template