-1

I have few questions which i have been asked in interview:

  1. Performance difference between delete and truncate?
  2. Delete duplicate data from a table which is not having any id column and should not use CTE.
  3. Why we are able to delete data using CTE?
4

2 回答 2

4
  1. DELETE记录每个单独TRUNCATE的删除,而是批量记录操作,因此速度更快。
  2. 您可以将SELECT DISTINCT数据放入临时表,TRUNCATE然后重新插入第一个表。
  3. 不是史酷比...
于 2012-06-09T17:25:57.550 回答
1

以下是解决您问题的一些提示:

  1. 由于 TRUNCATE 实际上并不删除数据,而是通过删除指向索引的指针来释放数据,因此它比 DELETE 快得多,当您使用 DELETE 时,所有内容都逐行存储在事务日志中,因此速度要慢得多。

  2. http://www.codeproject.com/Tips/159881/How-to-remove-duplicate-rows-in-SQL-Server-2008-wh

  3. http://blog.sqlauthority.com/2009/06/23/sql-server-2005-2008-delete-duplicate-rows/

于 2012-06-09T17:36:48.887 回答