1)确定正在使用的UNDO表空间
10:17:26 SQL> show parameter undo_tablespace;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace                      string      UNDOTBS1
2)显示数据库所有的UNDO表空间
10:18:38 SQL> select tablespace_name from dba_tablespaces
10:18:39   2    where contents='UNDO';
TABLESPACE_NAME
------------------------------
UNDOTBS1
3)显示UNDO表空间的统计信息
10:20:26 SQL> select to_char(begin_time,'HH24:MI:SS') BEGIN_TIME,
10:20:28   2    TO_CHAR(END_TIME,'HH24:MI:SS') END_TIME, UNDOBLKS
10:20:57   3   FROM V$UNDOSTAT;
BEGIN_TI END_TIME   UNDOBLKS
-------- -------- ----------
10:15:21 10:21:08          2
10:05:21 10:15:21         38
09:55:21 10:05:21         29
Oracle 每隔10分钟生成一行统计信息。
4)显示UNDO段统计信息
使用自动UNDO管理模式时,Oracle会在UNDO表空间上自动建立10个UNDO段。
V$ROLLNAME,可以显示所有联机UNDO段的名称;V$ROLLSTAT,显示UNDO段的统计信息。
10:25:15 SQL> select a.name,b.xacts,b.writes,b.extents
10:25:17   2    from v$rollname a ,v$rollstat b
10:25:33   3    where a.usn=b.usn;
NAME                                XACTS     WRITES    EXTENTS
------------------------------ ---------- ---------- ----------
SYSTEM                                  0      38546          6
_SYSSMU1$                               0     231028         17
_SYSSMU2$                               0      43268          4
_SYSSMU3$                               0      29870          6
_SYSSMU4$                               0      20430          3
_SYSSMU5$                               0      59402         42
_SYSSMU6$                               0      22900         56
_SYSSMU7$                               0      23734         17
_SYSSMU8$                               0      22908          4
_SYSSMU9$                               0      20744          3
_SYSSMU10$                              0      38916          3
11 rows selected.
XACTS用于标识UNDO段所包含的活动事务个数,writes 用于标识在UNDO段上所写入的字节数,extents用于标识UNDO段的区个数。
5)显示活动事务信息
10:30:45 SQL> conn scott/tiger
Connected.
10:31:35 SQL> update emp set sal=3000 where empno=7369;
1 row updated.
10:28:30 SQL> col username format a10
10:28:32 SQL> col name format a10
10:28:41 SQL> select a.username,b.name,c.used_ublk
10:28:56   2    from v$session a ,v$rollname b,v$transaction c
10:29:27   3    where a.saddr=c.ses_addr and b.usn=c.xidusn 
10:29:53   4     and a.username='SCOTT';
USERNAME   NAME        USED_UBLK
---------- ---------- ----------
SCOTT      _SYSSMU8$           1
6)显示UNDO区信息
Dba_undo_extents 显示undo表空间所有区的详细信息。
10:35:19 SQL> select extent_id,bytes,status from dba_undo_extents
10:35:30   2   where segment_name='_SYSSMU8$';
 EXTENT_ID      BYTES STATUS
---------- ---------- ---------
         0      65536 EXPIRED
         1      65536 EXPIRED
         2      65536 EXPIRED
         3      65536 ACTIVE

CUUG

更多oracle视频教程请点击:http://crm2.qq.com/page/portalpage/wpa.php?uin=800060152&f=1&ty=1&aty=0&a=&from=6