回收undo表空间

采用如下步骤回收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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值