Home >Database >Mysql Tutorial >What is the mysql command to clear table data?

What is the mysql command to clear table data?

烟雨青岚
烟雨青岚Original
2020-06-11 09:28:027983browse

What is the mysql command to clear table data?

mysql clear table data command has the following two statements:

Statement 1:

delete from 表名;

Statement 2:

truncate table 表名;

Comparison:

(1) The delete statement without where parameter can be deleted All contents in the mysql table can also be cleared using truncate table.

(2) In terms of efficiency, truncate is faster than delete, but after truncate is deleted, the mysql log is not recorded and the data cannot be recovered.

(3) The effect of delete is a bit like deleting all the records in the mysql table one by one until the deletion is complete, while truncate is equivalent to retaining the structure of the mysql table and re-creating the table. All states are equivalent to new surface.

Recommended tutorial: "MySQL Tutorial"

The above is the detailed content of What is the mysql command to clear table data?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn