MySQL Truncate table
empties or clears out all the records from a table. The structure of the data remains untouched.
The basic syntax will be:
TRUNCATE TABLE table_name;
Some important points to remember about the Truncate statement are as follows:
Since the employee's table has a foreign key constraint on the ratings table, the below command fails.
The ratings table has two columns. rating_id
(int) which is the primary key and percentage (
float).
The employees table references the rating_id columns as a foreign key. The truncate does not affect either table since it fails.
truncate table employees;
The employee_subset table does not have any constraints or references to it. So the truncate table command works on it. The structure remains intact aas seen in the below image.
truncate table employee_subset;