重建TEMP表空间是最稳妥解法,因其不自动回收已分配临时段;需新建temp2、切换默认、确认无会话使用旧TEMP、再drop tablespace including contents and datafiles。temp 表空间不释放空间,不是因为没清理,而是因为 oracle 默认不自动回收已分配的临时段------直接重建 temp 是最稳妥的解法。TEMP 表空间使用率长期 100% 却查不到活跃排序这是典型现象:dba_temp_free_space 显示已用 100%,但 vsort_usage 或 vsession 找不到大排序会话。原因在于临时文件(tempfile)一旦扩展,Oracle 不会自动收缩,即使所有排序结束,空间仍被标记为"已分配但空闲"。别信 alter database tempfile ... resize 能直接缩容------若高位有未释放的区(extent),会报错 ORA-03297: file contains used data beyond requested RESIZE value检查真实空闲空间用:select tablespace_name, round((free_blocks*block_size)/1024/1024) free_mb from vtemp_space_header;(注意是 vtemp_space_header,不是 dba_free_space)临时表空间不支持 shrink space,任何试图对 tempfile 做 shrink 的操作都会失败重建 TEMP 表空间的最小安全步骤必须在数据库 open 状态下完成,无需停机,但需确保无应用正在执行大规模排序或建索引(否则新 TEMP 尚未就绪时会报错 ORA-01652: unable to extend temp segment)。新建临时表空间:create temporary tablespace temp2 tempfile '/u01/oradata/ORCL/temp02.dbf' size 1024m autoextend on next 100m maxsize 8g;切换默认临时表空间:alter database default temporary tablespace temp2;确认无会话还在用旧 TEMP:select sid, serial#, username, program from v$session where tempseg_used > 0 and tablespace = 'TEMP';(结果应为空)删除旧 TEMP:drop tablespace temp including contents and datafiles;(加 including contents 才能删掉里面的临时段)为什么不能只删 tempfile、保留表空间?临时表空间可以没有 tempfile,但此时任何需要排序的操作都会立即失败------Oracle 不允许 tempfile 全部 offline 或全部被 rm 掉后还维持表空间存在。 MacsMind 电商AI超级智能客服
相关推荐
ITenderL3 分钟前
MySQL联合索引遇到范围查询0566464 小时前
agent学习Day15——SQLAlchemy 查询过滤、分页与历史列表接口程序员爱德华5 小时前
Python与C++:异同点对比hangyuekejiGEO5 小时前
GEO技术服务选型指南敲个大西瓜6 小时前
Redis一百道核心面试题软萌萌的16 小时前
Java Spring Boot 修改yml配置&加载顺序规则Dxy12393102167 小时前
Linux 编译安装 Python 3.12.10(多版本共存,不破坏系统Python)持敬chijing8 小时前
Python概述無a伟9 小时前
Redis持久化详解:RDB与AOF原理、配置、优缺点