解决Oracle 表空间UNDOTBS1太大的问题

UNDOTBS1是一个回滚表空间,随着数据库的使用,默认会自动扩展。当它增大到一定程度,占用了过多的磁盘空间时,就需要进行清理了。下面就在2种操作系统下讲解清理该表空间的方法。


一、环境:windows xp;数据库:Oracle 9i。


在windows系统下,无法完全使用命令行方式操作数据库。具体步骤如下:


1. 启动PLSQL工具连接数据库,登录信息:system/password@DBSID as sysdba;新建一个command window;


2. 创建一个新的回滚段表空间:


SQL> create undo tablespace undotbs2 datafile '%oracle_home%/oradata/DBSID/undotbs02.dbf' size 500M;


Tablespace created.


3. 将回滚段指向新的表空间:


SQL> alter system set undo_tablespace=undotbs2 scope=spfile;


System altered.


4. 重新启动数据库:


在windows环境下,该步无法使用命令行操作;


在系统服务项中,重启oracle的关键服务:


OracleOraHome92TNSListener


OracleServiceDBSID


5. PLSQL重新连接数据库:system/password@DBSID as sysdba;新建command window;


Oracle 9i默认自动管理回滚段,为了防止其无限制增长,可以将其设为人工管理:


SQL> alter system set undo_management =MANUAL scope=spfile;


System altered.


(本人建议:还是让数据库自动管理回滚段比较好,可以定期清理该表空间)


6. 重新启动数据库(参照步骤4)


7. 删除原来的回滚空间:


PLSQL重新连接数据库:system/password@DBSID as sysdba;新建command window;


SQL> drop tablespace undotbs1 including contents and datafiles;


Tablespace dropped.


该步骤只能删除数据库对该空间的管理信息,要想完全删除该表空间文件,需要到相应的目录下手动删除;


8. 结束


二、环境:linux;数据库:Oracle 9i。


1. 登陆到数据库

oracle@suse:~> sqlplus '/as sysdba'

SQL*Plus: Release 9.2.0.4.0 - Production on 星期一 10月 10 17:24:26 2011

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production

2. 创建一个新的回滚段表空间

SQL> create undo tablespace undotbs2 datafile '%oracle_home%/oradata/DBSID/undotbs02.dbf' size 500M;

Tablespace created.


3. 将回滚段指向新的表空间

SQL> alter system set undo_tablespace=undotbs2 scope=spfile;

System altered.

4. 重新启动数据库

SQL> startup force
ORACLE instance started.

Total System Global Area 688985728 bytes
Fixed Size 452224 bytes
Variable Size 671088640 bytes
Database Buffers 16777216 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.

5. 因为oracle9i默认是自动管理回滚段,为了防止其无限制的增长,可以将其设置为人工管理:
SQL> alter system set undo_management =MANUAL scope=spfile;

System altered.

6. 重新启动数据库:

SQL> startup force
ORACLE instance started.

Total System Global Area 688985728 bytes
Fixed Size 452224 bytes
Variable Size 671088640 bytes
Database Buffers 16777216 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.

7. 删除原来的回滚段:
SQL> drop tablespace undotbs1 including contents and datafiles;

Tablespace dropped.

8. 退出

SQL> quit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production。
************************
select segment_name,bytes from user_segments where tablespace_name='COLLEGE_DATA' order by byte
truncate table
**************************


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值