加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle temp表空间爆满的处理方法

发布时间:2020-12-12 15:57:04 所属栏目:百科 来源:网络整理
导读:当数据库进行索引重建,或者大量数据导入导出时,会使得temp表空间暴增,很可能撑满数据文件,因为数据库安装的时候,temp表空间默认很自由一个数据文件 并且数据库中单个数据文件最大只能自增到32G,当超过32G时就不可用了,为了防止此故障发生,在做索引重

当数据库进行索引重建,或者大量数据导入导出时,会使得temp表空间暴增,很可能撑满数据文件,因为数据库安装的时候,temp表空间默认很自由一个数据文件
并且数据库中单个数据文件最大只能自增到32G,当超过32G时就不可用了,为了防止此故障发生,在做索引重建或者大量数据导入导出时,需要关注temp表空间
的增长情况,temp表空间过大时,可通过如下方法重建
SQL> create temporary tablespace temp2 tempfile '/opt/oracle/oradata/conner/temp1.dbf' size 200M autoextend off;
SQL> alter database default temporary tablespace temp2;
SQL> drop tablespace temp;

或者SQL> drop tablespace temp including contents and datafiles cascade constraints(彻底删除包括操作系统中的临时表空间的数据文件)
最后在操作系统上把temp的文件删除,就可以释放空间。

还可以改为原来的temp
SQL> create temporary tablespace temp tempfile '/opt/oracle/oradata/conner/temp.dbf' size 200M autoextend off;
SQL> alter database default temporary tablespace temp;
SQL> drop tablespace temp2;
最后在操作系统上把temp的文件删除,就可以释放空间。

注意:如果是DG环境,则在主库上完成以上操作后,还得在备库中给新创建的临时表空间增加数据文件,备库不用创建新的临时表空间,DG会自动从主库同步临时表空间到备库(但是临时表空间的数据文件是不能同步过去的,需要手动添加)

SQL>alter tablespace temp1 add tempfile '/u01/app/oracle/orcl/temp1.dbf' size 500m autoextend on next 100m;

查看临时表空间(dba_temp_files视图)(v$tempfile视图)
select tablespace_name,file_name,bytes/1024/1024 file_size,autoextensible from dba_temp_files;
select status,enabled,name,bytes/1024/1024 file_size from v$tempfile;--sys用户查看

查询默认临时表空间
select * from database_properties where property_name='DEFAULT_TEMP_TABLESPACE';

select username,temporary_tablespace,default_ from dba_users;
更多temp表空间维护可参考:http://www.blogjava.net/japper/archive/2012/06/28/381721.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读