当前位置:网站首页>MySQL empties table data
MySQL empties table data
2022-07-01 21:55:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Clear the table data There are three ways
1 、truncate ( fast ) The auto increment field is cleared from 1 Start Empty the whole table first
2、drop Delete table directly … Nothing, nothing … … … …
3、delete Slow batch The auto increment field is not empty
MySQL Clear table data command :truncate
explain : Delete content 、 Free space without deleting definition , That is, the structure of the data table is still . And drop The difference is , It just empties the table data , It's gentle .
truncate table Table name
Be careful :
Cannot be associated with where Use it together . truncate Deleting data is not allowed rollback Of . truncate After deleting the data, it will reset Identity( Identity column 、 Self increasing field ), It is equivalent to that the auto increment column will be set to the initial value , Again from 1 Start recording , Instead of following the original ID Count . truncate Do not write to the server after deleting data log, The overall deletion speed is fast . truncate Do not activate after deleting data trigger( trigger ).
MySQL Delete table command :drop
explain : Delete content and definition , Release space . To put it simply, take out the whole table . It is impossible to add new data in the future , Unless a new table is added .
drop table Table name ;
Or is it Add conditions
drop table if exists Table name
Be careful :
drop Not only clear the table data, but also delete the table structure .
MySQL Syntax for clearing the contents of the data table :delete
explain : Deleting content does not delete definition , Don't free up space . among ,delete table tb Although it is also to delete the data of the whole table , But the process is painful ( The system deletes... Line by line , More efficient truncate low ).
delete from Table name where id='1';
Or is it Without conditions
delete from Table name ;
Be careful :
delete meaning : Which table data do you want to delete ? Which lines do you want to delete ? delete You can delete a line , You can also delete multiple lines ; If not where Conditions , Delete all data in the table , It's very dangerous ! This is not recommended !
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/130488.html Link to the original text :https://javaforall.cn
边栏推荐
- 游览器打开摄像头案例
- CNN卷积神经网络原理讲解+图片识别应用(附源码)[通俗易懂]
- Significance and measures of security encryption of industrial control equipment
- 柒微自动发卡系统源码
- MySQL系列之事务日志Redo log学习笔记
- 杰理之、产线装配环节【篇】
- 基于K-means的用户画像聚类模型
- I received a letter from CTO inviting me to interview machine learning engineer
- Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
- Can I choose to open an account for stock trading on flush? Is it safe?
猜你喜欢
随机推荐
【mysql 07】GPG key retrieval failed: “Couldn‘t open file /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022“
MySQL系列之事务日志Redo log学习笔记
Introduction and download of the latest version of airserver2022
BC35&BC95 ONENET MQTT(旧)
【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程
上半年暂停考试要补考?包含监理工程师、建筑师等十项考试
MIT|256KB 内存下的设备上训练
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
Aidl basic use
人才近悦远来,望城区夯实“强省会”智力底座
PWN攻防世界cgpwn2
杰理之蓝牙耳机品控和生产技巧【篇】
新版Free手机、PC、平板、笔记本四端网站缩略展示图在线一键生成网站源码
AirServer2022最新版功能介绍及下载
I received a letter from CTO inviting me to interview machine learning engineer
【级联分类器训练参数】Training Haar Cascades
Case of camera opening by tour
从20s优化到500ms,我用了这三招
杰理之蓝牙耳机品控和生产技巧【篇】
C中main函数的几种写法