Open Source RDBMS - Seamless, Scalable, Stable and Free

English | Login |Register

(click on this box to dismiss)

What is the difference between truncate and delete

What is the difference between TRUNCATE table and DELETE * FROM table? When should I use TRUNCATE and when should I use DELETE?

링크 댓글 쓰기 (0)
질문시간 3년 전

the first and most important is that TRUNCATE is faster!

both of them will empty your table. but "delete * from table" will be ready to commit after rows were merged and ready to rollback. in case of triggers or constraints, delete will hurt you more. 

the delete triggers will take time also when you'll use delete. so ... once again, TRUNCATE is the better choice.

as for a transaction log ... also TRUNCATE rules.

when TRUNCATE is not good ? when you'll need to delete just a few rows from your table (ex: delete * from table where id<5 )

링크 댓글 쓰기 (0)
답변시간 3년 전

You are either using a very old browser or a browser that is not supported.
In order to browse you need to have one of the following browsers:

Internet Explorer: Mozilla Firefox: Google Chrome: