--查看某个表空间信息
select tablespace_name,file_name,bytes/1024/1024 from dba_data_files where tablespace_name like 'UNDOTBS1';
--查看回滚段的使用情况,哪个用户正在使用回滚段的资源,如果有用户最好更换时间(特别是生产环境)。
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;
--检查UNDO Segment状态
select usn,xacts,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks from v$rollstat order by rssize;
--创建新的UNDO表空间,并设置自动扩展参数;
create undo tablespace undotbs2 datafile 'D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\UNDOTBS02.DBF' size 10m reuse autoextend on next 100m maxsize unlimited;
-- 动态更改spfile配置文件;
alter system set undo_tablespace=undotbs2 scope=both;
--等待原UNDO表空间所有UNDO SEGMENT OFFLINE;
select usn,xacts,status,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks from v$rollstat order by rssize;
--再执行看UNDO表空间所有UNDO SEGMENT ONLINE;
select usn,xacts,status,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks from v$rollstat order by rssize;
-- 删除原有的UNDO表空间;
drop tablespace undotbs1 including contents;