undo表的问题

参考来源: http://www.cnblogs.com/jyzhao/p/5733761.html

起因

项目中大佬给了我一个任务,说是数据库的一个运维指标过高让我改一下,原来都没有怎么接触过数据库
将查询的结果记录一下,原因语句也给我了 delete from xxxx

undo

What Is Undo?
undo是什么:
Every Oracle Database must have a method of maintaining information that is used to roll back, or undo, changes to the database.
每个Oracle数据库都必须有一种方法来维护用于回滚或撤消数据库更改的信息。

Such information consists of records of the actions of transactions, primarily before they are committed.These records are collectively referred to as undo.
在事务提交之前,保存事务行为的记录信息统称为undo。

Undo records are used to:
undo记录信息经常用于:

Roll back transactions when a ROLLBACK statement is issued
当发出ROLLBACK语句时回滚事务

Recover the database
恢复数据库

Provide read consistency
提供可读一致性

Analyze data as of an earlier point in time by using Oracle Flashback Query
使用oracle闪回语句的一个早期节点的分析数据

Recover from logical corruptions using Oracle Flashback features
使用Oracle闪回特性从逻辑错误中恢复

When a ROLLBACK statement is issued, undo records are used to undo changes that were made to the database by the uncommitted transaction.
当发出ROLLBACK语句时,undo用于记录撤消未提交事务对数据库所做的更改。

During database recovery, undo records are used to undo any uncommitted changes applied from the redo log to the datafiles.
在数据库恢复期间,撤消记录用于撤消从redo日志到数据文件的任何未提交的更改。

Undo records provide read consistency by maintaining the before image of the data for users who are accessing the data at the same time that another user is changing it.
撤消记录通过为在另一个用户更改数据的同时访问数据的用户保留数据的before映像来提供读取一致性。

The UNDO_RETENTION parameter is ignored for a fixed size undo tablespace.
UNDO_RETENTION 参数会被固定大小的sudo表忽略

The database may overwrite unexpired undo information when tablespace space becomes low.
当表空间变少的时候,数据库可能重写未到期的undo信息

For an undo tablespace with the AUTOEXTEND option enabled, the database attempts to honor the minimum retention period specified by UNDO_RETENTION.
对于一个自动扩张选项开启的undo表空间,数据库试图遵守由UNDO_RETENTION指定的最短保留期。

When space is low, instead of overwriting unexpired undo information, the tablespace auto-extends.
当空间很小的时候,自动扩张表空间来代替重写未到期的undo信息

If the MAXSIZE clause is specified for an auto-extending undo tablespace, when the maximum size is reached, the database may begin to overwrite unexpired undo information.
当自动扩张的undo表空间的最大空间由MAXSIZE 条款指定,如果达到最大空间,数据库可能去重写未到期的undo信息

最后

看到这里其实也很简单,那张表比较大,几千万的数据,每次delete并为了能够为了提供回滚,undo当然就比较大
解决方案:使用TRUNCATE删除整表

TRUNCATE TABLE 则一次性地从表中删除所有的数据并不把单独的删除操作记录记入日志保存,删除行是不能恢复的。并且在删除的过程中不会激活与表有关的删除触发器。执行速度快。

经过上面的翻译也可以知道为什么undo表使用空间会是一个运维指标,如果undo表一直比较大,可能无法提供回滚要的空间导致回滚失败,并且可能无法恢复指定的最短保留时间内的数据(因为空间不够的重写)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值