删除UNDO表空间并处理ORA-01548问题

本文详细介绍了如何在Oracle数据库中删除UNDO表空间,包括创建新的UNDO表空间、切换系统使用的UNDO表空间、检查并删除内容过期的表空间,以及在遇到ORA-01548错误时采用的解决方案,如使用OFFLINE和逻辑备份等方法。

http://blog.itpub.net/31394774/viewspace-2220984/

 

-新建一个undo表空间
 create undo tablespace UNDOTBS2 datafile '/app/oracle/oradata/BIEEDB/undotbs02.dbf' size 15G autoextend on next 100M maxsize 30G;
 alter system set undo_tablespace=UNDOTBS2 scope=both;
 alter tablespace UNDOTBS1 offline;
 --删除表空间前腰确保表空间里面的内容都已过期:当结果为空时才可以删除表空间
 select extent_id, status from dba_undo_extents where tablespace_name='UNDOTBS1' and status <> 'EXPIRED';
 --重启数据库
通过命令行方式登录数据库,
[root$smserver] sqlplus /nolog 
[root$smserver]conn / as sysdba 
[root$smserver] shutdown immediate;
[root$smserver] startup
 drop tablespace UNDOTBS1 including contents and datafiles;

 

 

undo表空间的切换:

1、先检查现在正在使用的undo表空间:

SQL> show parameter undo_tablespace

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

undo_tablespace                      string      UNDOTBS1

 

 

1.找到所有的表空间文件,这里主要是找到计划删除undo表空间

1

select * from dba_data_files;

 

2.新建一个 undo 表空间,表空间名字和物理文件名字都换一个,自拓展的参数自行调整

1

create undo tablespace UNDOTBS3 datafile '/u01/app/oracle/oradata/cams/undotbs03.dbf' size 100M autoextend on next 100M maxsize unlimited;

 

3.修改系统的 undo 表空间为新创建的 undo 表空间

1

alter system set undo_tablespace=UNDOTBS3;

 

4.查看当前的UNDO表空间

1

2

3

4

5

6

7

SYS@cams> show parameter undo;

  

NAME         TYPE  VALUE

------------------------------------ ----------- ------------------------------

undo_management       string  AUTO

undo_retention        integer  900

undo_tablespace       string  UNDOTBS3

 

undo表空间的删除

删除表空间前腰确保表空间里面的内容都已过期:

select extent_id, status from dba_undo_extents where tablespace_name='UNDOTBS1' and status <> 'EXPIRED';

当结果为空时才可以删除表空间

drop tablespace UNDOTBS1 including contents and datafiles;

 

问题说明

5.此时直接删除原 undo 表空间和表空间文件,遇到 ORA-01548 的错误。

1

2

3

4

5

6

7

SYS@cams> drop tablespace UNDOTBS1 including contents and datafiles;

  

drop tablespace UNDOTBS1 including contents and datafiles

*

ERROR at line 1:

ORA-01548: active rollback segment '_SYSSMU9_1650507775$' found, terminate

dropping tablespace

 

 

实操方案  

6.因为本次操作的环境是测试环境,所以选择了一个最简单快速的方法,表空间offline+drop。

如果担心数据损坏,建议做一个expdp/exp逻辑备份。

1

2

3

4

5

6

7

SYS@cams> alter tablespace UNDOTBS1 offline;

  

Tablespace altered.

  

SYS@cams> drop tablespace UNDOTBS1 including contents and datafiles;

  

Tablespace dropped.

注:如果不着急的话,可以将数据库的默认undo表空间修改之后运行一段时间,查看dba_rollback_segs  表,等到原undo表空间中只剩下“offline”状态的segment时( 如果有事务未提交,可以执行commit force命令强制提交 ),可以顺利删除。

 

7.完事检查是否已经成功删除

1

2

3

4

5

SYS@cams> select count(*) from dba_tablespaces where tablespace_name='UNDOTBS1'

  

  COUNT(*)

----------

 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值