Mysql add, dele...LOGIN

Mysql add, delete, modify, delete records

Use delete to delete records

CategoryDetailed explanation
Basic syntaxDELETE FROM table [where condition];
ExampleDELETE FROM user where id > 10;
Example descriptionDelete all users with ID greater than 10 in the user table

user table, the table structure is as follows:

##16Chen He1234131.00
idusernamebalance
1王宝强50000.00
2黄晓明150000000.00
15马云15000.00
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. This auto-increment field will restore the starting value to 1.

CategoryDescriptionBasic syntaxTRUNCATE TABLE table name;ExampleTRUNCATE TABLE user;Example descriptionClear the table data and let the auto-incremented id start from 1

【Remember】

    Be sure to remember to add the where condition when deleting, otherwise the records in the entire table will be cleared.
  1. Be sure to back up, back up, back up before deleting important data.
Next Section
<?php echo "Hello Mysql"; ?>
submitReset Code
ChapterCourseware