如何 重建undo表空间

如果一个undo表空间已经扩展到一定大小,并且硬盘空间吃紧,可以优先考虑将undo表空间重建,再观察和评估后续的方案。同时如何杜绝以后undo表空间过大的问题,原理可处理方式可以参考这篇文章。oracle undo表空间过大

查看当前使用的undo表空间

 show parameter undo;select * from v$parameter ;

重建undo表空间

create undo tablespace undotbs2 datafile 'D:\ORADB\ORADATA\ORCL\UNDOTBS201.DBF' size 4G autoextend off; alter tablespace undotbs2 add datafile 'D:\ORADB\ORADATA\ORCL\UNDOTBS202.DBF' size 4G autoextend off ;

切换表空间

alter system set undo_tablespace=undotbs2 scope=both;

查看当前的undo1 的回滚段状态

select segment_name,tablespace_name,status from dba_rollback_segs t where tablespace_name='UNDOTBS1' and status='ONLINE'

下线在线的回滚段

ALTER ROLLBACK SEGMENT "_SYSSMU9$" OFFLINE;

查找到相关的事务ID

SELECT s.sid,serial#, u.name ,r.status FROM v$transaction t, v$rollstat r, v$rollname u, v$session s WHERE s.taddr = t.addr AND t.xidusn = r.usn AND r.usn =u.usn and r.status='PENDING OFFLINE' ;

删除旧undo表空间

 drop tablespace undotbs1 including contents and datafiles;