This lesson discusses how to delete all the rows of a table using the TRUNCATE clause.

We'll cover the following


In the previous lesson, we learned how to delete data using the DELETE statement. However, if we intend to delete all the rows from a table then a faster route is to use the TRUNCATE statement. Generally, we don’t want to delete all the table rows except in the case of temporary tables. The TRUNCATE statement drops a table and recreates it for faster processing. MySQL doesn’t count the number of rows affected and may show the count to be zero or non-zero, but the number doesn’t reflect the actual number of rows affected.

Example Syntax


Connect to the terminal below by clicking in the widget. Once connected, the command line prompt will show up. Enter or copy and paste the command ./DataJek/Lessons/ and wait for the MySQL prompt to start-up.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.