Difference between truncate and delete all query in MySQL?

truncate query

  • Truncate command delete all the rows from a table in faster manner.
  • truncate query is a DDL (Data Definition Language) query
  • truncate query reset the auto increment counter of a table

Sample Code

truncate table student_info
delete query
  • With delete query we can delete all or selective records. It is slower as compare to truncate query.
  • delete query is DML (Data Manipulation Language) query.
  • delete query does not reset the auto increment counter of a table

Sample Code

delete from student_info; #delete all the records
delete from student_info where student_id='30'; #delete student records who's id is 30