暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

oracle 管理UNDO表空间

原创 大汉_客家族_小凡仙 2022-10-30
1456

管理UNDO表空间

使用UNDO参数

  1.  UNDO_MANAGEMENT
    

该初始化参数用于指定UNDO数据的管理方式。自动管理为AUTO,手工管理为MANUAL,Oracle10默认为ATUO
2) UNDO_TABLESPACE
指定例程所要使用的UNDO表空间
3) UNDO_RETENTION
控制UNDO数据的最大保留时间,默认为900秒

建立UNDO表空间

  1.  使用CREATE DATABASE命令建立UNDO表空间
    
Create database db01 ……. Undo tablespace undotbs_01 Datafile ‘/undo.dbf’ size 10m
  1.  使用CREATE UNDO TABLESPACE命令建立UNDO表空间
    
SQL> create undo tablespace undotbs3 2 datafile 'f:\demo\undotbs3.dbf' size 10m;

表空间已创建。

修改UNDO表空间

SQL> alter tablespace undotbs3 add datafile 2 'f:\demo\undotbs3_2.dbf' size 5m;

表空间已更改。

切换UNDO表空间

SQL> alter system set undo_tablespace=undotbs1; 删除UNDO表空间 SQL> drop tablespace undotbs3;

表空间已删除。
手工删除文件

监视UNDO空间信息

  1.  确定当前例程正在使用的UNDO表空间
    
SQL> show parameter undo_tablespace NAME TYPE VALUE ------------------------------------ ----------- --------- undo_tablespace string UNDOTBS1
  1.  显示数据库的所有UNDO表空间
    
Sql>select tablespace_name from dba_tablespaces Where contents=’undo
  1.  显示UNDO表空间统计信息 
    
SQL> select to_char(begin_time,'hh24:mi:ss') begin_time, to_char(end_time,'hh24:mi:ss') end_time, undoblks from v$undostat; BEGIN_TI END_TIME UNDOBLKS -------- -------- ---------- 10:53:09 11:00:37 1

4)显示UNDO段统计信息

SQL> select a.name,b.xacts,b.writes,b.extents 2 from v$rollname a,v$rollstat b 3 where a.usn=b.usn; NAME XACTS WRITES EXTENTS ------------------------------ ---------- ---------- ---------- SYSTEM 0 5000 6 _SYSSMU1$ 0 9300 27 _SYSSMU2$ 0 2954 21 _SYSSMU3$ 0 5474 16 _SYSSMU4$ 0 3612 30 _SYSSMU5$ 0 2506 25 _SYSSMU6$ 0 92062 29 _SYSSMU7$ 0 119364 22 _SYSSMU8$ 0 13456 38 _SYSSMU9$ 0 3148 13 _SYSSMU10$ 0 2074 11 已选择11行。

5.显示活动事务信息
SQL> col username format a10
SQL> col name format a10
SQL> select a.username,b.name ,c.used_ublk
2 from vsessiona,vsession a,vrollname b,vtransaction c 3 where a.saddr=c.ses_addr and b.usn=c.xidusn 4 and a.username='scott'; 未选定行 6)显示UNDO信息 select extent_id,bytes,status, from dba_undo_extents where segment_name='_syssmu5’
Type of Undo segments
System:used for objects in the system tablespace
None-system: used for objects int other tablespaces:
Automode: Require an undo tablespace
Manual mode:
Private:Acquired by single instance
Public: Acquired by any instance
Deffered(延迟):Used when tablespace are taken offline immediate,temporary,or for recovery
SQL> alter tablespace lyh offline immediate;
表空间已更改。
SQL> alter tablespace lyh online;
alter tablespace lyh online
*
第 1 行出现错误:
ORA-01113: 文件 5 需要介质恢复
ORA-01110: 数据文件 5: ‘F:\DEMO\LYH.DBF’
SQL> recover datafile ‘F:\DEMO\LYH.DBF’;
完成介质恢复。
SQL> alter tablespace lyh online;
表空间已更改。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论