September 6, 2006 at 6:26 pm
Hi,
If one table contains 200 million rows, what's the faster SQL scripts can clear all rows in that table? Among Delete, Truncate and Drop, which is the best for performance?
Delete?
Truncate?
Drop and Create new table?
regards.
September 6, 2006 at 7:22 pm
Hi Nizam,
I think it depends on what you need exactly,
if u need to clear all rows in the table using "delete" syntax,
but if u need to delete the table also using "drop" syntax...
I don't think the difference between those syntax are about how fast the execution time, but only in the functionality.
September 6, 2006 at 7:22 pm
Hi Nizam,
I think it depends on what you need exactly,
if u need to clear all rows in the table using "delete" syntax,
but if u need to delete the table also using "drop" syntax...
I don't think the difference between those syntax are about how fast the execution time, but only in the functionality.
September 6, 2006 at 7:22 pm
Hi Nizam,
I think it depends on what you need exactly,
if u need to clear all rows in the table using "delete" syntax,
but if u need to delete the table also using "drop" syntax...
I don't think the difference between those syntax are about how fast the execution time, but only in the functionality.
September 6, 2006 at 7:28 pm
Unless you want the log to remember that you deleted 200 million rows, DELETE is NOT the way to go...
TRUNCATE is absolutely the fastest way to empty a table, without logging and without disturbing the schema.
If you have foreign keys and you're deleting from the parent table, neither truncate nor delete will work until you clear the children. The exception to that rule is that you can delete from a parent even if children are present if the foreign keys are of the CASCADE ON DELETE nature.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 6, 2006 at 8:06 pm
Delete on table with lot of rows will take a lot of time to commit all those Xaction.
If you want to wipe away then use Truncate table
Thanks
Sreejith
September 10, 2006 at 3:30 am
Also depends if the table has an Identity column. If you need the identity column reset, i think you should be using TRUNCATE.
Correct me if am wrong!!
September 10, 2006 at 9:18 am
You are not wrong. Conversely, if you don't want the IDENTITY column to be reset to the SEED value, you must use DELETE, instead.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply