What is the difference for delete/truncate/drop
Same:
delete/truncate/drop, all of them can support rollback/commit, the sample is as below:
begin tran T1
truncate table TestTable
rollback/commit
Difference:
delete can support where clause, but truncate/drop cannot, that is because truncate/drop is for whole table level
delete records will leave the used index there, but truncate will set up new index from 0 started
Note:
We should know that, once the transaction is committed, we cannot do rollback anymore.
By default, did any write operation, it is committed like below, so we cannot recover the lost data
delete from TestTable
If do the transaction to drop table, but don't commit it, at this time to refresh the database, it will get below error:
What is the difference for delete/truncate/drop的更多相关文章
- delete/truncate/drop table的区别以及锁在这里的角色
数据库删除语句 Drop/Delete/Truncate比较 Delete :删除数据表中的行(可以删除某一行,也可以在不删除数据表的情况下删除所有行). 删除某一行:Delete from 数据表名 ...
- 关于sql 中delete, truncate,drop的理解与总结
关于文章,本文是在网上查找资料整理而来,方便以后记忆 delete 命令删除的数据可以恢复, truncate 命令删除的数据是不可以恢复的,全删的那种 drop 命令删除的数据不可恢复,连表结构都删 ...
- sql之truncate 、delete与drop区别
sql之truncate .delete与drop区别相同点:truncate 和不带 where 子句的 delete,以及 drop 一定会删除表内的数据不同点:1. truncate 和 del ...
- ECSHOP后台SQL查询提示错误 this sql May contain UPDATE,DELETE,TRUNCATE,ALTER,DROP,FLUSH,INSERT
一).首先说一下错误现象:市面上流行的绝大部分ECSHOP模板,安装的时候都需要执行一段或几段SQL语句来修改数据结构或者初始化一些数据.大多数ECSHOP管理员为了省事,都会通过 “ECSHOP后台 ...
- Truncate table、Delete与Drop table的区别
Truncate table.Delete与Drop table的区别 TRUNCATE TABLE 在功能上与不带 WHERE 子句的 DELETE 语句相同:二者均删除表中的全部行.但 TRUNC ...
- drop,delete,truncate区别
drop,delete,truncate区别 drop-->删除少量信息 eg:drop table 表名: delete-->删除某些数据 eg:delete from 表名: ...
- truncate与delete 、drop的区别
注意事项 1.在oracle中数据删除后还能回滚是因为它把原始数据放到了undo表空间. 2.DML语句使用undo表空间,DDL语句不使用undo, 而delete是DML语句,truncate是 ...
- sql中truncate 、delete与drop区别
SQL truncate .delete与drop区别 相同点: 1.truncate和不带where子句的delete.以及drop都会删除表内的数据. 2.drop.truncate都是DDL ...
- SQL truncate 、delete与drop区别
SQL truncate .delete与drop区别 相同点: 1.truncate和不带where子句的delete.以及drop都会删除表内的数据. 2.drop.truncate都是DDL语句 ...
随机推荐
- hdoj 1251 字典树||map
统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submi ...
- canvas一周一练 -- canvas基础学习
从上个星期开始,耳朵就一直在生病,里面长了个疙瘩,肿的一碰就疼,不能吃饭不能嗨 (┳_┳)……在此提醒各位小伙伴,最近天气炎热,一定要注意防暑上火,病来如山倒呀~ 接下来我正在喝着5块一颗的药学习ca ...
- CJOJ 1087 【NOIP2010】乌龟棋 / Luogu 1541 乌龟棋(动态规划)
CJOJ 1087 [NOIP2010]乌龟棋 / Luogu 1541 乌龟棋(动态规划) Description 小明过生日的时候,爸爸送给他一副乌龟棋当作礼物. 乌龟棋的棋盘是一行N个格子,每个 ...
- mysql主从数据库设置备忘
[mysqld] binlog-do-db = databasename1 binlog-do-db = databasename2 binlog-do-db = databasename3 -- 且 ...
- Threads(线程)(二)
前一章我们提到了同步异步,多线程:在开始今天的文章之前,先来总结一下上一篇文章的内容,多线程的优点. 多线程有哪些优点呢,在这里通过代码依次来总结. 异步多线程的三大特点 1)同步方法卡界面,原因是主 ...
- docker~save与load的使用
回到目录 对于没有私有仓库来说,将本地镜像放到其它服务器上执行时,我们可以使用save和load方法,前者用来把镜像保存一个tar文件,后台从一个tar文件恢复成一个镜像,这个功能对于我们开发者来说还 ...
- Objectiv-C UIKit基础 NSLayoutConstraint的使用(VFL实现)
利用VFL可视化语言 (简单的抛砖引玉) 构建3个View 橙色和绿色左中右间隔20 上间隔40 高为200 蓝色在橙色内(0,0)处 宽高为橙色的一半 实现效果如下 由于atutosize和auto ...
- 【D3】transition API
摘要: 动画类API 一.API 使用 1. 1 d3.ease 1.2 d3.timer Start a custom animation timer, invoking the specified ...
- 定时任务FluentScheduler 学习笔记 .net
第一步添加引用 GitHub源码地址 与详细用法 https://github.com/fluentscheduler/FluentScheduler 下面开始简单的实现 /// <summar ...
- Git在tortoiseGit以及eclipse的使用方法
一.Git安装与简单使用 1.安装git,tortoiseGit 2.创建SSH Key 打开Git Bash,然后输入ssh-keygen生成公钥和私钥: 3.生成ppk文件. 打开puttykey ...