Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropping an entire table

Tags:

sql

sql-server

I plan to delete an entire table with over 930,000 rows of data. Which is the best way to do it without increasing the Log size or increasing the DB size.

I am on a live site and my hosting has given me 150 MB of space..I am already using 125 MB and hence need to be careful of the DB size since increase in log will increase the size of my DB

like image 731
lols Avatar asked Dec 17 '22 07:12

lols


2 Answers

If you do not wish or need to fully log the deletion activity(i.e. you do not need to be able to recover your database to a specific point in time) then you can flush/deallocate the contents of the table by using the TRUNCATE TABLE command.

If on the other hand you wish to log the event fully then you should delete the data in batches in order to maximise performance, see the following article for details on how to do this:

Performing Fast SQL Server Delete Operations

like image 183
John Sansom Avatar answered Dec 21 '22 23:12

John Sansom


use truncate table.

like image 37
Vincent Buck Avatar answered Dec 21 '22 23:12

Vincent Buck