Get the App
SLTechnology News&Howtos  ›  Database  › 

Statements for emptying table data in mysql database

Shulou Source: shulou.com Published: 2022-06-01 17:05:20 09月16日 Update

The mysql empty table data command has the following two statements:

Statement 1:

Delete from table name

Statement 2:

Truncate table table name

Compare:

(1) the delete statement without the where parameter can delete all the contents of the mysql table, and use truncate table to empty all the contents of the mysql table.

(2) truncate is faster than delete in efficiency, but mysql logs are not recorded after truncate deletion, and data cannot be recovered.

(3) the effect of delete is a bit like deleting all the records in the mysql table to the end, while truncate is equivalent to retaining the structure of the mysql table and recreating the table, and all the states are equivalent to the new table.

What is the above command for mysql to clear the table data? For more details, please pay attention to other related articles!

Tags: Statements data content commands parameters that is effects efficiency articles logs more status structure database Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple Shulou Technology Linux NVidia