Truncate table SQL query

If you need to delete all data from a table, you can use the TRUNCATE TABLE SQL query. This will delete all rows from the table and reset the auto-increment value to 0.

TRUNCATE TABLE table_name;

The truncate table SQL query is a command that is used to delete all the data from a table in a database. This command is often used when it is necessary to start fresh with a new table. The truncate table SQL query is a very powerful command and should be used with caution.

# Example: Delete all data from a table

Let's assume we have a table called Fruits that contain multiple rows and columns as below.

If you want to delete all the rows from the Fruits table, then you can use the below SQL query.


Was this helpful?