How to monitor database change

本文介绍了三种监控SQL表活动的方法:一是使用Profiler或服务器端跟踪并过滤表名以查看所有活动;二是创建存储过程来处理插入、更新和删除操作,并记录日志;三是通过触发器记录所有数据修改操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

There are few ways to do it.  

 

1. The first way is to start up profiler
or set up server side trace and filter the textdata column with the
table's name.  This way you'll see all activities on the table
including select statements.

2. Another way is to create stored procedure for insert, update and
delete statement.  In the stored procedures you can insert a record
into log table with the details that you need.  You can revoke insert,
update and delete statement on the table and let users work with the
stored procedure only.  Notice that anyone that belongs to db_owner
role or sysadmin server role will still be able to work directly with
the table.

3. Another option is to create trigger on the table for update, insert
and delete.  In the trigger you can log anything into a log table.
This way you will be able to log all data modification operations
regardless the way that it was done (direct SQL statement or through
stored procedure).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值