Home  >  Article  >  Database  >  小议truncate、drop、delete的区别

小议truncate、drop、delete的区别

WBOY
WBOYOriginal
2016-06-07 14:58:581092browse

小议truncate、drop、delete的区别 1、从分类角度 truncate、drop属于DDL(Data Definition Language 数据定义语言) delete属于DML(Data Manipulation Language 数据操作语言) 2、从表结构角度 truncate、delete只删除数据,不删除表结构 drop删除数据和表结

小议truncate、drop、delete的区别

 

1、从分类角度

truncate、drop属于DDL(Data Definition Language 数据定义语言)

delete属于DML(Data Manipulation Language 数据操作语言)

 

 2、从表结构角度 

truncate、delete只删除数据,不删除表结构

drop删除数据和表结构

 

 3、从安全角度

truncate、drop不支持回滚

delete支持

 

 4、从速率角度(如图)

drop table Employees和truncate table Employees查询开销为0%

delete from  Employees查询开销为95%

delete from  Employees where dep_id = 3查询开销为5%

 

从执行计划查询开销来看,drop 等于truncate,delete from tab where……速度大于delete from tab

 

小议truncate、drop、delete的区别

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn