Delete Record

Use delete to delete records


QQ截图20161009162523.png


##user table, the table structure is as follows:


QQ截图20161009162532.png


##mysql> delete from user where id = 1;

Query OK, 1 row affected (0.08 sec)


Delete the record of the row with ID 1, Li Wenkai.

Clear table records

delete and truncate are the same, but they have one difference, that is, DELETE can return the number of deleted records, while TRUNCATE TABLE returns 0.

If there is an auto-increment field in a table, use truncate table to restore the starting value to 1.


QQ截图20161009162540.png

QQ截图20161009162544.png


#【Remember】

1. When deleting, be sure to remember to add the where condition, otherwise the records in the entire table will be cleared.

2. Be sure to back up, back up, back up before deleting important data.

Continuing Learning
||
<?php echo "Hello Mysql"; ?>
submitReset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!