Delete large amount of data in sql server

后端 未结 7 1379
误落风尘
误落风尘 2021-02-15 15:30

Suppose that I have a table with 10000000 record. What is difference between this two solution?

  1. delete data like :

    DELETE FROM MyTable
             
    
    
            
7条回答
  •  既然无缘
    2021-02-15 16:03

    If you have that many records in your table and you want to delete them all, you should consider truncate

    instead of delete from
    . It will be much faster, but be aware that it cannot activate a trigger.

    See for more details (this case sql server 2000): http://msdn.microsoft.com/en-us/library/aa260621%28SQL.80%29.aspx

    Deleting the table within the application row by row will end up in long long time, as your dbms can not optimize anything, as it doesn't know in advance, that you are going to delete everything.

    提交回复
    热议问题