欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

t-sql清空表数据的两种方式示例(truncate and delete)

程序员文章站 2023-12-03 17:41:40
复制代码 代码如下:truncate table (transact-sql) removes all rows from a table without logging...

复制代码 代码如下:

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快,而且释放日志所占资源,不记录由于删除行的影响所产生的日志。