截断或删除并创建表 [英] Truncate or Drop and Create Table

查看:33
本文介绍了截断或删除并创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个 SQL Server 2008 R2 实例中有这个表,我有一个计划的进程每晚运行它.任何时候表中最多可以有 500K 条记录.处理此表后,我需要从中删除所有行,因此我想知道以下哪种方法会产生最少的开销(即过多的事务日志条目):

I have this table in a SQL Server 2008 R2 instance which I have a scheduled process that runs nightly against it. The table can have upward to 500K records in it at any one time. After processing this table I need to remove all rows from it so I am wondering which of the following methods would produce the least overhead (ie Excessive Transaction Log entries):

  1. 截断表
  2. 删除并重新创建表

由于时间和额外的事务日志条目,删除表的内容已结束.

Deleting the contents of the table is out due to time and extra Transaction log entries it makes.

共识似乎是截断,谢谢大家!

The consensus seems to be Truncation, Thanks everyone!

推荐答案

截断表格不会在事务日志中留下一行一行的条目 - 因此这两种解决方案都不会使您的日志过于混乱.如果是我,我会舍弃每次都必须删除和创建.

Truncating the table does not leave row-by-row entries in the transaction log - so neither solution will clutter up your logs too much. If it were me, I'd truncate over having to drop and create each time.

这篇关于截断或删除并创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆