MySQL delete statement

Although the database space is growing, but there are still times when processing data to be deleted, the following compiled some of the most popular delete statements.

One is divided into two kinds delete the specified data, delete all the other data.

First, delete the specified data

DELETE FROM table WHERE column name = value;

use xxx; # to enter the database
show tables; # View Data Sheet
select * from xxx;
delete from xxx where xx=xx;

If DELETE FROM table name 

Back without limitation, all data will be deleted, but still table structure, data can be recovered.

 

Second, delete all the data (and brought back)

TRUNCATE TABLE 表名;

 

The difference is that the former is still table structure, data can be retrieved; truncate statement is a direct drop off the table, and then create a new empty table, delete the data brought back, of course, its execution speed faster than the delete.

 

Guess you like

Origin www.cnblogs.com/Grayling/p/11008459.html