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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Inserting records into tables8m
-
(Locked)
Updating data records7m 33s
-
(Locked)
Challenge: Inserting and updating records1m 30s
-
(Locked)
Solution: Inserting and updating records7m 30s
-
(Locked)
Deleting specific records9m 41s
-
(Locked)
Deleting all records with TRUNCATE10m 28s
-
(Locked)
Challenge: Deleting records1m 32s
-
(Locked)
Solution: Deleting records8m 16s
-
(Locked)
-
-
-
-
-