UNDO表空间切换步骤

1.新建UNDO表空间

create undo tablespace UNDOTBS2 datafile '/data01/testdb/undotbs01.dbf' size 1G;
alter database datafile '/data01/testdb/undotbs01.dbf' resize 30g;
alter tablespace UNDOTBS2 add datafile '/data01/testdb/undotbs02.dbf' size 1g;

2.切换表空间

alter system set undo_tablespace = UNDOTBS2;

3.查看原有表空间的状态

select tablespace_name , status , count(*) from dba_rollback_segs WHERE TABLESPACE_NAME='UNDOTBS1' group by tablespace_name , status;

 4.第3步中有ONLINE的UNDO段,查看是哪个SESSION

  SELECT s.sid,
         s.serial#,
         S.STATUS,
         S.USERNAME,
         S.MODULE,
         S.MACHINE,
         s.sql_id,
         R.TABLESPACE_NAME,
         v.usn,
         segment_name,
         r.status,
         v.rssize / 1024 / 1024 mb
    FROM dba_rollback_segs r,
         v$rollstat v,
         v$transaction t,
         v$session s
   WHERE     r.segment_id = v.usn
         AND v.usn = t.xidusn
         AND t.addr = s.taddr
         AND TABLESPACE_NAME = 'UNDOTBS1'
ORDER BY segment_name;

找到对应的SESSION后,通知对应的team解决

5.待全部OFFLINE后,删除UNDOTBS1表空间

Drop tablespace UNDOTBS1 including contents and datafiles;

6.删除后,查看OS目录是否有变化

删除后,发现UNDO数据文件所在的目录并没有变化,使用命令sync也没有效果,猜测是这些文件只是索引被删除,实际的内容并没有被删除

查看哪些进程在使用这些文件

losf|grep  delete

找到这些进程,杀掉即可

SELECT S.SID,s.serial#,S.USERNAME,S.STATUS,S.MODULE,S.MACHINE FROM V$SESSION S,V$PROCESS P WHERE S.PADDR=P.ADDR AND P.SPID=41487;

 

posted @ 2020-06-03 08:02  monkey6  阅读(492)  评论(0编辑  收藏  举报