From the course: MySQL Database Administration

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Deleting all records with TRUNCATE

Deleting all records with TRUNCATE - MySQL Tutorial

From the course: MySQL Database Administration

Deleting all records with TRUNCATE

- [Instructor] So sometimes instead of wanting to delete one single record or a few records from a table, we'll want to remove all records from a table. And we can do that using the TRUNCATE TABLE statement. When we use TRUNCATE TABLE, the data is removed from the rows, but the column names, the data types, the column order, and any constraints that are placed on the table are all still going to be preserved. TRUNCATE TABLE is very similar to using DELETE that we talked about before without including a WHERE clause, but there are going to be some key differences. One key difference is that DELETE is an example of data manipulation language, it can be rolled back. Where TRUNCATE is actually part of data definition language. This surprises some people because they have very similar functions, but TRUNCATE is part of data definition language or DDL and DDL cannot be rolled back. Before we jump into Workbench to do an example, let's talk a little bit about the different types of languages…

Contents