本文介绍了绕过/跳过在sql server上执行的truncate语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我想要一个功能,如果有人刚刚在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
推荐答案
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语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!