Undo自动管理与手动管理

undo段自动管理
SQL> show parameter undo_management

将undo段改为手工管理
SQL> alter system set undo_management=manual scope=spfile;
SQL> startup force;

SQL> show parameter undo
SQL> select * from v$rollname;

SQL> create undo tablespace undotbs2 datafile '/u01/app/oracle/oradata/orcl/undotbs2.dbf' size 5m;
SQL> create rollback segment u1 tablespace undotbs2;
SQL> alter rollback segment u1 online;

SQL> select * from v$rollname;

SQL> set transaction use rollback segment u1;

监视还原

空间不足

SQL> create table big_t as select * from dba_objects;
SQL> insert into big_t select * from big_t;
/
/
SQL> commit;

SQL> select name from v$tablespace;
SQL> alter system set undo_tablespace='UNDOTBS2';

SQL> show user

SQL> delete big_t;

快照太旧

快照太旧错误实验:

当undo空间不足的时候,会覆盖commit事务所占用的undo数据,当进行查询的时候,会报ORA-1555,例如:

conn /as sysdba
grant select on dba_objects to scott;
grant select on v_$transaction to scott;
grant select on v_$session to scott;
grant select on v_$mystat to scott;
grant select on v_$database to scott;

将undo表空间的大小resize到30M

create undo tablespace undotbs3 datafile '/u01/app/oracle/oradata/orcl/undotbs3.dbf' size 30M;

alter system set undo_tablespace=undotbs3;

计算一下30M的undo表空间undo块的数量:

select (30*1024*1024)/8192 undo_num from dual;

UNDO_NUM
-----------------
3840

conn scott/tiger
create table t1 as select * from dba_objects;

查看当前系统的scn号:

select current_scn from v$database;

在696246时刻,t1表中的数量为:

select count(*) from t1;

将t1表中的数据删除:

delete t1;--------------先不要提交

查看当前会话的delete操作生成的undo块的数量:

select used_ublk from v$transaction where addr = (select taddr from v$session where sid = (select sid from v$mystat where rownum = 1));

commit;

这个时候,通过闪回查询来查看1127829这一点的数据:

select count(*) from t1 as of scn 1127829;

再开一个会话:

conn scott/tiger

create table t2 as select * from dba_objects;

delete t2;

查看当前会话的delete操作生成的undo块的数量:

select used_ublk from v$transaction where addr = (select taddr from v$session where sid = (select sid from v$mystat where rownum = 1));

commit;

这个时候,通过闪回查询来查看1127829这一点的数据:

先清一下内存:

conn / as sysdba

alter system flush buffer_cache;

alter system flush shared_pool;

查看1127829这一点的数据:

select count(*) from t1 as of scn 1127829;
*
ERROR at line 1:
ORA-01555: snapshot too old: rollback segment number 2 with name
"_SYSSMU2_967517682$" too small

报错,由于undo表空间太小,第一个会话中的undo数据被覆盖,所以报快照太旧错误

undo_retention

1、对于UNDO表空间的数据文件属性为autoextensible,则undo_retenion参数必须设置
UNDO信息将至少保留至undo_retention参数设定的值内,但UNDO表空间将会自动扩展

2、对于固定UNDO表空间,将会通过表空间的剩余空间来最大限度保留UNDO信息。如果FIXED UNDO
表空间没有对保留时间作GUARANTEE(alter tablespace xxx retention guarantee;),则undo_retention
参数将不会起作用(警告:如果设置UNDO表空间为retention guarantee,则未过期的数据不会被复写,如
果表空间不够则会导致DML操作失败或者transation挂起)

Guaranteeing Undo Retention
SQL> ALTER TABLESPACE undotbs1 RETENTION GUARANTEE;

观察undo数据块信息,业务高峰期时的数据
alter session set nsl_date_format='yyyy-mm-dd hh24:mi:ss';
select begin_time,end_time,undoblks from v$undostat;

UNDO:

不能直接查询undo块,可以查询CR块
操作块+Undo块=CR块(读一致性块)

grant select on v$database to scott;
conn scott/tiger;

create table t(id number);
insert into d values(1);
select * from d;
select current_scn from v$database;

insert into d values(2);
select * from d;
select * from d as of scn 1604457;

conn / as sysdba;
select tablespace_name, contents from dba_tablespaces;

conn scott/tiger;
create table tt tablespace undotbs1 as select * from dept;--error

conn / as sysdba;
show parameter undo_retention

OCA读书笔记(10) - 管理UNDO数据的更多相关文章

  1. OCA读书笔记(9) - 管理数据同步

    9.Managing Data Concurrency 描述锁机制以及oracle如何管理数据一致性监控和解决锁冲突 管理数据的并发--管理锁数据的不一致:脏读更改丢失幻影读 脏读:数据是指事务T2修 ...

  2. OCA读书笔记(7) - 管理数据库存储结构

    7.Managing Database Storage Structures 逻辑结构 数据库的存储结构有物理结构和逻辑结构组成的 物理结构:物理上,oracle是由一些操作系统文件组成的 SQL&g ...

  3. OCA读书笔记(8) - 管理用户安全

    创建用户:create user +用户 default tablespace + 表空间名 identified + 验证方式 SQL> create user easthome profil ...

  4. OCA读书笔记(5) - 管理ASM实例

    Objectives:Describe the benefits of using ASMManage the ASM instanceCreate and drop ASM disk groupsE ...

  5. OCA读书笔记(4) - 管理数据库实例

    Objectives: •Start and stop the Oracle database and components •Use Oracle Enterprise Manager •Acces ...

  6. 强化学习读书笔记 - 10 - on-policy控制的近似方法

    强化学习读书笔记 - 10 - on-policy控制的近似方法 学习笔记: Reinforcement Learning: An Introduction, Richard S. Sutton an ...

  7. OCP读书笔记(10) - 使用闪回技术I

    使用闪回技术查询数据 闪回查询:就是查询表在过去某个时间点的数据,所用到的技术就是undo数据 SQL> conn scott/tiger 创建测试表 SQL> create table ...

  8. 《SQL Server企业级平台管理实践》读书笔记——SQL Server中数据文件空间使用与管理

    1.表和索引存储结构 在SQL Server2005以前,一个表格是以一个B树或者一个堆(heap)存放的.每个B树或者堆,在sysindexes里面都有一条记录相对应.SQL Server2005以 ...

  9. 数据段描述符和代码段描述符(一)——《x86汇编语言:从实模式到保护模式》读书笔记10

    一.段描述符的分类 在上一篇博文中已经说过,为了使用段,我们必须要创建段描述符.80X86中有各种各样的段描述符,下图展示了它们的分类. 看了上图,你也许会说:天啊,怎么这么多段描述符啊!我可怎么记住 ...

随机推荐

  1. ADO.NET 2SqlDataAdapter、DataSet 的基本用法

    数据集完全独立于数据源,可以与数据源链接或者完全断开,其基本作用是为存储在内存缓存中的的数据提供关系视图 如果只是想读取和显示数据,则值需要使用数据读取器,尤其是处理大量数据的时候 如果需要处理数据, ...

  2. HDU 1599 find the mincost route (无向图floyd最小环详解)

    转载请注明出处:http://blog.csdn.net/a1dark 分析:终于弄懂了floyd的原理.以前的理解一直肤浅.所以一做到floyd应用的题.就拙计了.其实floyd的本质DP.利用前K ...

  3. [Java聊天室server]实战之二 监听类

    前言 学习不论什么一个稍有难度的技术,要对其有充分理性的分析,之后果断做出决定---->也就是人们常说的"多谋善断":本系列尽管涉及的是socket相关的知识,但学习之前,更 ...

  4. android https通过载入pfx证书获取数据

    直接给代码吧.研究了几天才搞定...... public static final String CLIENT_KET_PASSWORD = "Ku6OpqKDfN4=305790" ...

  5. 使用POI来实现对Excel的读写操作

    事实上我感觉直接贴代码就好了.代码里面差点儿做到每一行一个凝视.应该看起来会比較简单 代码托管在github上:https://github.com/chsj1/ExcelUtils package ...

  6. EasyUI - DataGrid 组建 - [ 样式功能 ]

    效果显示: 同上次博文效果. html代码: 同上次博文代码. js代码: align: 'center',//标题和内容居中 resizable: false,//不允许改变大小 //hidden: ...

  7. 【linux】linux内核移植错误记录

       欢迎转载,转载时请保留作者信息,谢谢. 邮箱:tangzhongp@163.com 博客园地址:http://www.cnblogs.com/embedded-tzp Csdn博客地址:http ...

  8. javascript 中 事件流和事件冒泡

    一.事件流 是描述页面接受事件的顺序,IE 使用的是时间冒泡流;而Netscape的事件采用的是事件捕获流.1.事件冒泡JS 和 HTML是通过事件的方式实现交互.事件冒泡 开始元素,将事件逐级传递, ...

  9. perl Exporter一些神奇写法

    use base qw(Exporter); @JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_j ...

  10. HEVC码率控制浅析——HM代码阅读之四

    继续分析第一篇提到的compressSlice中对LCU的RC参数初始化: #if RATE_CONTROL_LAMBDA_DOMAIN Double oldLambda = m_pcRdCost-& ...