Home > Database > Mysql Tutorial > body text

What is the mysql command to clear table data?

烟雨青岚
Release: 2020-06-11 09:28:02
Original
7952 people have browsed it

What is the mysql command to clear table data?

mysql clear table data command has the following two statements:

Statement 1:

delete from 表名;
Copy after login

Statement 2:

truncate table 表名;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!