我如何使用触发器? [英] how i can use of trigger?

查看:71
本文介绍了我如何使用触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过触发器保护sql server中数据的完整性.

How to protect of integrity of data in sql server by triggers.

请发送一个例子为我.

谢谢.

推荐答案

Sql服务器触发器通常不用于保护数据的完整性.实际上是控制操作的地方.

但是,如果您确实要为此使用触发器,则可以在执行插入操作之前检查该块中的值.

实现触发器非常简单.使用本教程开始入门:
http://www.devarticles.com/c /a/SQL-Server/Using-Triggers-In-MS-SQL-Server/1/ [
Sql server Triggers are not generally used to protect integrity of data. It is actually a place to control the operation.

But if you really want to use Triggers for this, you might check the value inside that block before doing the insert.

Implementing Triggers is very simple. Use this tutorial to get started :
http://www.devarticles.com/c/a/SQL-Server/Using-Triggers-In-MS-SQL-Server/1/[^]

:rose:


保护数据的最佳方法是使用约束,但是如果您要确保例如字符串是给定格式,则在插入数据时会触发触发器,并可以对其进行检查并接受或拒绝该插入内容.您也可以具有用于更新和删除的触发器.我写的任何例子的深度都没有Google所能找到的那么多,在撰写的文章中,他们比任何论坛的答复都更加谨慎.
The best way to protect your data is with constraints, but if you mean, for example, making sure a string is a given format, a trigger can fire when you insert data, and can check it and accept or reject the insert.  You can have triggers for updates and deletes, too.  Any example I write will not be as in depth as the many you can find with google, in articles that were written with more care than any forum reply.


这篇关于我如何使用触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆