DELETE FROM sometable
TRUNCATE TABLE sometable
These 2 statements are functionally equivalent except for the following:
- DELETE usually executes more slowly than TRUNCATE
- DELETE returns a row count indicating the number of records deleted while TRUNCATE always returns a row count of zero.
- TRUNCATE will reset any AUTO_INCREMENT fields to 1 while DELETE will maintain the current AUTO_INCREMENT value (note that there are exceptions to this depending on the type of database engine and version of MySQL).
No comments:
Post a Comment