Mysql table three kinds delete operation

Copyright: welcome the exchange of learning, please indicate the source. https://blog.csdn.net/qq_23869697/article/details/91453716

1. Delete operation

(1) Delete the entire table does not retain any information

drop table table name
such as:

drop table student

Data (2) deleting the table, the table retention structure

truncate (table) table
, such as:

truncate (table) student

Or
delete from table name
such as:

delete from student
delete from student where age < 21

And delete the difference 2.truncate

rollback WHERE and use Reset Index return value
truncate NO NO YES NO
delete YES YES NO The number of rows deleted

3. Notes

For table increment field, delete insert operation after the fault should pay attention to the problem from growing.
After using the delete all data into a new data you want to maintain increment from the beginning, we need to use
delete from student where ture.
Otherwise, the next index will be removed before the start of the last index increment.
Use truncate table to delete data will automatically reset the index increment of 1.

Reference: https://www.cnblogs.com/shuaiandjun/p/6042600.html
https://www.cnblogs.com/fcc-123/p/10672604.html

Guess you like

Origin blog.csdn.net/qq_23869697/article/details/91453716