undo表空间缩小

     最近执行一个数据量比较大的存储过程,造成undo表空间达到16g左右,但是直接采用resize的方式又无法缩小其大

小,因此经网上搜索,采用了undo表空间重建的方式来缩小去空间大小,具体步骤如下:

1)创建备用undo表空间

create undo tablespace newundotbs datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\TELEMT\newUNDOTBS01.DBF' size 2500m

2)切换undo表空间为新建的undo表空间

alter system set undo_tablespace=newundotbs scope=spfile
shutdown immediate
startup

3)drop原表空间

drop tablespace UNDOTBS1 including contents and datafiles
然后将数据库关闭删除D:\ORACLE\PRODUCT\10.2.0\ORADATA\TELEMT\UNDOTBS01.DBF该文件
如果无法删除查看v$transaction视图看是否有事务在执行,若有可以与v$session关联找出sid和serial#并kill掉,然后再dropundotbs1表空间

4)创建原undo表空间
create undo tablespace UNDOTBS1 datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\TELEMT\UNDOTBS01.DBF' size 2500m

5)再切换undo表空间为原来的undo表空间

alter system set undo_tablespace=UNDOTBS1 scope=spfile

6)关闭重起并把备用undo表空间drop
shutdown immediate
startup
drop tablespace newundotbs including contents and datafiles

原文地址:https://www.cnblogs.com/lanzi/p/2076695.html