为什么截断DDL语句? [英] Why is truncate a DDL statement?

查看:87
本文介绍了为什么截断DDL语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在truncate语句之后,表结构保持不变,并且仅删除记录(使用自动提交).那么,截断是DDL语句的原因是什么?

The table structure remains same after truncate statement and only records get deleted (with auto commit). Then what is the reason that truncate is a DDL statement ?

推荐答案

我将在此处添加一些说明: 默认情况下,截断表时,您不只是删除行,还隐式地告诉Oracle数据库还执行以下任务:

I'd add here some explanation: By default, when truncating a table , you are not just removing rows, you are implicitly telling Oracle Database to also perform the following tasks:

取消分配被删除的行使用的所有空间,除了MINEXTENTS存储参数指定的空间

Deallocates all space used by the removed rows except that specified by the MINEXTENTS storage parameter

将NEXT存储参数设置为通过截断过程从段中删除的最后一个扩展区的大小

Sets the NEXT storage parameter to the size of the last extent removed from the segment by the truncation process

因此,它通过重置高水位标记来更改存储定义和更改表的结构.

So, it changes the storage definitions and changing the structure of the table by resetting the water high mark.

也不能是DML,对吗? 无法指定where子句或DDL语句附带该子句.如果truncate是DML语句,那么Oracle允许我们将truncate与where子句一起使用.
注意:SQL中的WHERE子句指定SQL数据操作语言(DML)语句仅影响符合指定条件的行.

Also it can't be a DML ,right? Where clause can't be specified or comes along with DDL statement. If truncate is a DML statement then Oracle would have allowed us to use truncate along with where clause.
Note: A WHERE clause in SQL specifies that a SQL Data Manipulation Language (DML) statement should only affect rows that meet specified criteria.

这篇关于为什么截断DDL语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆