Truncate table sql query

Truncate table sql query

Blog Bustle 06/03/2020

Truncate table sql query is used to empty table or delete all records from table. Remember that after running this truncate table sql query, we will not able to retrieve table data. So we should be careful.

Truncate table sql query syntax

truncate table table_name;

For example, i want to empty subject table from student database and truncate table sql query will be

truncate table subject;

truncate table sql query

Points to remember:

We can also run " delete from subject; " query to delete records from subject table but truncate table sql query is fast process to empty table.

First we have to select database before running any query related to that database otherwise we will get 'no database selected' error.

If we think table whom we want to empty, its data can be useful for future, then we should take table backup.

Hope you like this tutorial.

Other important links

Mysql database and table backup

Insert query in sql

Update query in sql

Delete query in sql

Select query in sql

Truncate table sql query searches:

Tags: #mysql