触发器
来源:互联网 发布:淘宝设置粉丝圈 编辑:程序博客网 时间:2024/04/30 05:00
简介:某个条件成立的时候触发器里面所定义的语句就会被自动执行。
概括:create trigger mytrigger--在T_Users表上创建 update触发器
on T_Users--表名
for update
print 'the table was update--by 小猪也无奈!'--如果触发update则输出the table was update--by 小猪也无奈
-执行后会发现 会输出设置好的the table was update--by 小猪也无奈
update T_Users set UserName='小猪'-
where UserName='T_User
修改触发器只需要把create改为alter
alter trigger mytrigger
on T_Users
for update
as
print '修改触发器完成'
--关闭或者开启触发器
Go
disable trigger mytrigger on database --禁用触发器
Go
enable trigger mytrigger on database --开启触发器
--执行修改语句的时,触发器就会终止执行
Go
alter trigger mytrigger on T_Users
for update
as
if exists (select * from T_Users
where UserName='new Table')
rollback
Go
update T_Users set UserName='xiaozhu'
where UserName='qwe'
目的:更好的保护数据表,当执行操作时,就会触发定义好的操作过程,从而终止执行。如删除,程序就会自动执行触发器里面定义的操作过程
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 触发器
- 封装
- 性能优化——内存优化(2)
- JS常见对象方法小结
- MATLAB 神经网络模板
- 【Hive】Hive0.13.1的安装及Hive运行RuntimeException Cannot make directory错误的解决
- 触发器
- IntentServcie实现分析
- 73. Set Matrix Zeroes
- Light oj 1003 - Drunk(拓扑排序, DAG)
- Python 网络爬虫 001 (科普) 网络爬虫简介
- POJ 3480 John (Nim博弈)
- set容器的用法
- 既然睡不着
- poj 1692