当前位置:网站首页>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
边栏推荐
- Aidl basic use
- 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
- UVM教程
- matlab遍历图像、字符串数组等基本操作
- BlocProvider 为什么感觉和 Provider 很相似?
- 基于YOLOv5的口罩佩戴检测方法
- 物联网rfid等
- 同花顺股票开户选哪个券商好手机开户是安全么?
- I received a letter from CTO inviting me to interview machine learning engineer
- [noip2013] building block competition [noip2018] road laying greed / difference
猜你喜欢
新版图解网络PDF即将发布
【智能QbD风险评估工具】上海道宁为您带来LeanQbD介绍、试用、教程
Application of real estate management based on 3D GIS
Introduction à l'ingénierie logicielle (sixième édition) notes d'examen de Zhang haifan
基于LSTM模型实现新闻分类
基于三维GIS的不动产管理应用
手动实现function isInstanceOf(child,Parent)
名单揭晓 | 2021年度中国杰出知识产权服务团队
十三届蓝桥杯B组国赛
杰理之蓝牙耳机品控和生产技巧【篇】
随机推荐
杰理之、产线装配环节【篇】
AIDL基本使用
2022熔化焊接与热切割上岗证题目模拟考试平台操作
杰理之、产线装配环节【篇】
burpsuite简单抓包教程[通俗易懂]
Electron学习(三)之简单交互操作
杰理之蓝牙耳机品控和生产技巧【篇】
ICML2022 | 基于元语义正则化的介入性对比学习
Accelera Systems Initiative是一个独立的非营利组织
Introduction and download of the latest version of airserver2022
AirServer手机第三方投屏电脑软件
杰理之蓝牙耳机品控和生产技巧【篇】
[deep learning] use deep learning to monitor your girlfriend's wechat chat?
PMP与NPDP之间的区别是什么?
从20s优化到500ms,我用了这三招
新版Free手机、PC、平板、笔记本四端网站缩略展示图在线一键生成网站源码
在技术升级中迎合消费者需求,安吉尔净水器“价值战”的竞争之道
焱融看 | 混合云时代下,如何制定多云策略
东哥套现,大佬隐退?
Halcon知识:三维重构的一个尝试