SQL TRUNCATE TABLE

SQL TRUNCATE TABLE

 SQL TRUNCATE TABLE


Use MySQL TRUNCATE TABLE statement to delete all table content. This doesn’t remote table structure. The truncate table also reset the auto-increment values.

Syntax:

TRUNCATE TABLE table_name

MySQL Truncate Table Statement

For example, to remove all data from a table named users use the following command. You must select the database first before running the below command.

Example – MySQL Truncate Table

For example, I have a table named users with the following records in a database. First, check the available data in the table. After that truncate table and again check.

Now execute the truncate table statement on the user's table.

mysql> TRUNCATE TABLE users;

After running the truncate table statement, again check the table values.

mysql> SELECT * FROM users;

Empty set (0.00 sec)
Reactions

Post a Comment

0 Comments

close