采用如下步骤回收UNDO空间:
1.确认文件
select file_name,bytes/1024/1024 from dba_data_files
where tablespace_name like 'UNDOTBS1';
2.检查UNDO Segment状态
set linesize 200;
select usn,xacts,status,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks from v$rollstat order by rssize;
--查看回滚段的使用情况,哪个用户正在使用回滚段的资源,如果有用户最好更换时间(特别是生产环境)。
select s.username, u.name
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 order by s.username;
3.创建新的UNDO表空间
create undo tablespace undotbs2 datafile 'E:\ORACLE\ORADATA\WINDDB\UNDOTBS02.DBF' size 1000m reuse autoextend on next 100m maxsize unlimited;
--drop tablespace undotbs2 including contents;
4.切换UNDO表空间为新的UNDO表空间
alter system set undo_tablespace=undotbs2 scope=both;
alter system set undo_tablespace=undotbs2 scope=pfile;
alter system set undo_tablespace=undotbs2 scope=spfile;
或手式修改init*.ora文件
此处使用spfile需要注意,以前曾经记录过这样一个案例,Oracle诊断案例-Spfile案例一则。另外,如果使用的RAC环境,请注意,修改spfile时,要指定sid参数。
5.等待原UNDO表空间所有UNDO SEGMENT OFFLINE
select usn,xacts,status,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks from v$rollstat order by rssize;
或重启数据库清理undo空间数据
6.删除原UNDO表空间
drop tablespace undotbs1 including contents;
7.检查空间情况
select file_name,bytes/1024/1024 from dba_data_files where tablespace_name like 'UNDOTBS1';
select file_name,bytes/1024/1024 from dba_data_files where tablespace_name like 'UNDOTBS2';
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/70109/viewspace-687162/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/70109/viewspace-687162/