There are two ways to delete data in MySQL:
Delete Operation If you need to clear all the data in the table, you can do either of the following: delete from tablename; truncate table tablename; If you only want to delete part of the data, you can only use delete: the difference When deleting some data in a granular manner, only delete can be used. Return Value The return value of truncate is 0, while delete returns the number of deleted records. mysql> truncate serviceHost; Query OK, 0 rows affected (0.04 sec) mysql> delete from serviceHost where creator='test'; Query OK, 4 rows affected (0.01 sec) Auto-increment field If there is an auto-increment field in the table, truncate will reset it to 1, while delete will keep the maximum auto-increment value. Execution efficiency Truncate does not scan the table, which is equivalent to recreating the table, retaining only the table structure, and then deleting the original table, which is very efficient. Operation log Truncate does not write to the server log and cannot be recovered. trigger Truncate does not activate the trigger, but delete does. Summarize The above is the two ways to clear MySQL table data and their differences that I introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Detailed explanation of JavaScript closure issues
>>: Steps to deploy Docker project in IDEA
There are two ways to configure multiple projects...
All tags must be lowercase In XHTML, all tags must...
Usually the pictures uploaded by users need to be...
Table of contents Throttling and anti-shake conce...
Table of contents 1. Deconstruction Tips 2. Digit...
The specific code for using jQuery to implement t...
First download JDK. Here we use jdk-8u181-linux-x...
This article shares the specific code of jQuery t...
Table of contents 1. Overview 2. Django Project 3...
Analyze the production steps: 1. Prepare resource...
View the installation information of mysql: #ps -...
For detailed documentation on installing the comp...
Change the default style of select, usually throug...
Use the find command to find files larger than a ...
This article example shares the specific code of ...