SQL Truncate table 权限

TRUNCATE TABLE 命令用于快速删除表中所有行,但不记录单行删除操作,节省资源。它需要比db_writer更高的权限,如ALTER权限。默认情况下,表所有者、sysadmin、db_owner和db_ddladmin角色拥有此权限。若要授予他人使用,可通过grant alter权限或在存储过程中使用EXECUTE AS。
摘要由CSDN通过智能技术生成
对于一些很大的表,如果要删除数据用Truncate table比Delete效果要好。
TRUNCATE TABLE (Transact-SQL)

Removes all rows from a table without logging the individual row deletions. TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause; however, TRUNCATE TABLE is faster and uses fewer system and transaction log resources.

但是Truncate table需要的权限比较高(db_writer权限是不够的),所以比较矛盾。

Permissions

The minimum permission required is ALTER on table_name. TRUNCATE TABLE permissions default to the table owner, members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles, and are not transferable. However, you can incorporate the TRUNCATE TABLE stateme

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值