当前位置:网站首页>Mysql database: the difference between drop, truncate and delete
Mysql database: the difference between drop, truncate and delete
2022-06-29 22:44:00 【Full stack programmer webmaster】
1、 Delete speed :drop>truncate>delete;
2、 Delete by :
- (1) perform delete In operation , Delete one row at a time from the table , At the same time, the deletion of this line is recorded in the log file .delete According to the where Conditions delete the specified in the table data , If you don't specify where Clause , Then follow truncate equally , You can delete all records in the table .
- (2)truncate Delete data by freeing the pages used to store table data , Delete all records in the table at once , The deleted data will not be recorded in the log file , Only the release of pages is recorded in the log file , Less system and transaction log resources used , So the execution speed is faster than delete fast . For tables referenced by foreign key constraints , Out of commission truncate table, Instead, it should be used without where Clause delete sentence .
- (3)drop Delete the structure and data of the entire table , But the constraints that are relied upon 、 trigger 、 Indexes 、 Stored procedures that depend on the table 、 The function will be reserved , But its state will change to invalid
3、 After deleting , Table and index space :
- (1)delete The operation does not reduce the space occupied by the table or index ;
- (2) When the watch is truncate after , The space occupied by this table and index will be restored to the original size , But the structure of the table and its columns 、 constraint 、 The definition of the index remains unchanged .
- (3)drop Statement to free up all the space occupied by the table .
4、 submission :delete yes DML, Manual submission is required to take effect , You can roll back , Triggers can be triggered ;truncate and drop yes DDL, Will implicitly submit , Cannot be rolled back , It doesn't trigger .
5、 Use scenarios :
- (1) If you want to delete a table , Of course with drop;
- (2) If you want to keep the table and delete all the data , And it has nothing to do with transactions , use truncate that will do ;
- (3) If it's about business , Or want to trigger trigger, Or use it delete;
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/100076.html Link to the original text :https://javaforall.cn
边栏推荐
- Free PDF to word software sharing, these software must know!
- Digital tracking analysis of insurance services in the first quarter of 2022
- LeetCode85+105+114+124
- 还天天熬夜加班做报表?其实你根本不懂如何高效做报表
- 关于深度学习的概念理解(笔记)
- MooseFS基本概念总结
- 5 - 1 Analyse de vulnérabilité du système
- Realizing deep learning framework from zero -- RNN from theory to practice [practice]
- An in-depth analysis of the election mechanism in kubernetes
- Detailed description of gaussdb (DWS) complex and diverse resource load management methods
猜你喜欢

解题元宇宙,网络游戏中的多元通信方案

IFLYTEK AI learning machine summer new product launch AI + education depth combination to create a new height of products

Online text digit recognition list summation tool

Daily mathematics serial 54: February 23

低代码、端到端,一小时构建IoT示例场景,声网发布灵隼物联网云平台

啃下大骨头——排序(一)

26 years old, 0 basic career change software test, from 3K to 16K monthly salary, a super complete learning guide compiled by me
![Realizing deep learning framework from zero -- RNN from theory to practice [practice]](/img/a0/d64b69dec4a8f3a3dbc2eb47df9372.png)
Realizing deep learning framework from zero -- RNN from theory to practice [practice]

交友平台小程序制作开发代码分享

Basic use of Nacos configuration center
随机推荐
Grep工具
Efficient implementation of dynamiccast with template function and specialization function
[proteus simulation] digital tube display of stepping motor speed
The details of industry are all made by money and time
在线文本数字识别列表求和工具
Taishan Office Technology Lecture: all elements in a row have the same height
leetcode 416. Partition equal subset sum partition equal subset sum (medium)
LeetCode85+105+114+124
低代码、端到端,一小时构建IoT示例场景,声网发布灵隼物联网云平台
论文浅尝 | KR-GCN: 知识感知推理的可解释推荐系统
js函数相关的复习
PhpSpreadsheet读写Excel文件
Static keyword continuation, inheritance, rewrite, polymorphism
【Proteus仿真】步进电机转速数码管显示
Deep parsing of kubernetes controller runtime
R & D test time ratio, bug data analysis
26 years old, 0 basic career change software test, from 3K to 16K monthly salary, a super complete learning guide compiled by me
合宙AIR32F103CBT6开发板上手报告
Digital tracking analysis of insurance services in the first quarter of 2022
laravel 关联模型 多态关系