绕过/跳过在sql server上执行的truncate语句 [英] Bypass/Skip truncate statement executed on sql server
问题描述
你好,
我想要一个功能,如果有人刚刚在sql server上执行截断表mytable,那么它不应该被截断,我检查我发现有DDL触发drop table和alter table但是当我执行truncate命令时,DDL触发器不会被执行,另一个选项是删除sysadmin权限给用户和一些特定权限,
但是我想知道还有其他方法来处理这种情况吗?
提前谢谢,
谢谢,
Dhiraj
Hello,
I want a functionality that if someone just executed truncate table mytable on sql server, then it should not get truncated, I checked I found there are DDL triggers for drop table and alter table but when i execute truncate command the DDL triggers does not get executed, Another option will be remove sysadmin permissions to user and some specific permissions only,
But I want to know is there any other way to handle this scenario?
Thanks in advance,
Thanks,
Dhiraj
推荐答案
正如MSDN所说,没有办法拦截这个。最大的问题是,为什么你允许用户这样做,如果你不想要它们,你不相信它们不会?
As MSDN says, there's no way to intercept this. The biggest question would be, why do you allow users to do this, if you don't want them to, AND you don't trust them not to ?
你遇到了需要的问题地址。
话虽如此......
You got problems you need to address.
Having said that...
Restrictions
You cannot use TRUNCATE TABLE on tables that:
•Are referenced by a FOREIGN KEY constraint. (You can truncate a table that has a foreign key that references itself.)
•Participate in an indexed view.
•Are published by using transactional replication or merge replication.
这篇关于绕过/跳过在sql server上执行的truncate语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!