MySQL Tutorial
TRUNCATE TABLE command is used to delete complete data from an existing table.
TRUNCATE TABLE doesn't delete the structure of the table.
TRUNCATE TABLE table_name;
Let's perform the truncate operation on a database table.
Consider we've an Students table in our database with the following records:
ROLL_NO | NAME | SUBJECT |
---|---|---|
1 | Will | C++ |
2 | SAM | Python |
3 | Sara | HTML | 4 | Rim | Java |
5 | Micheal | MySQL |
6 | Lara |
The following command removes all the rows from the Students table:
TRUNCATE TABLE Students;
Now, after executing the above MySQL statement,
You can also use DROP TABLE command to delete complete table but it would remove complete table structure form the database