问题描述:删临时文件时报错ORA-01258,如下所示:
数据库:oracle 19.13
系统:rhel 7.9
1、异常重现
SQL> alter tablespace temp drop tempfile '/u01/app/oracle/oradata/orcl/temp01.dbf';
ORA-01258: unable to delete temporary file /u01/app/oracle/oradata/orcl/temp01.dbf
后台日志:
Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_60875.trc:
ORA-01122: database file 201 failed verification check
ORA-01110: data file 201: '/u01/app/oracle/oradata/orcl/temp01.dbf'
ORA-01565: error in identifying file '/u01/app/oracle/oradata/orcl/temp01.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2023-05-25T10:57:11.055790+08:00
Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_60875.trc:
ORA-01258: unable to delete temporary file /u01/app/oracle/oradata/orcl/temp01.dbf
2、异常原因
无法获得临时文件temp01.dbf状态.
3、解决方案
--查临时文件.
SQL> select tablespace_name,file_name from dba_temp_files;
TABLESPACE_NAME FILE_NAME
------------------------------ --------------------------------------------------------------------------------
LOAN_TEMP /u01/app/oracle/oradata/orcl/LOAN_TEMP.DBF
TEMP /u01/app/oracle/oradata/orcl/temp01.dbf
TEMP /u01/app/oracle/oradata/orcl/temp1.dbf
说明:通过如上语句查出临时文件,但在系统层面并未找到temp01.dbf文件.
官方针对ORA-25152描述如下:
ORA-25152: TEMPFILE cannot be dropped at this time
Cause: An attempt was made to drop a TEMPFILE being used by online users
Action: The TEMPFILE has been taken offline. Try again later.
--很大可能临时表空间被占用,查占用临时表空间的会话信息:
SELECT s.sid,
s.username,
s.status,
u.tablespace,
u.segfile#,
u.contents,
u.extents,
u.blocks
FROM v$session s, v$sort_usage u
WHERE s.saddr = u.session_addr
ORDER BY u.tablespace, u.segfile#, u.segblk#, u.blocks;
SID USERNAME STATUS TABLESPACE SEGFILE# CONTENTS EXTENTS BLOCKS
---------- -------------------- -------- --------------- ---------- --------- ---------- ----------
1184 ACTIVE TEMP 201 TEMPORARY 1 128
300 ACTIVE TEMP 201 TEMPORARY 1 128
300 ACTIVE TEMP 201 TEMPORARY 1 128
327 ACTIVE TEMP 201 TEMPORARY 1 128
327 ACTIVE TEMP 201 TEMPORARY 1 128
1437 ACTIVE TEMP 201 TEMPORARY 1 128
1184 ACTIVE TEMP 201 TEMPORARY 1 128
1437 ACTIVE TEMP 201 TEMPORARY 2 256
--查具体会话信息
select s."SID", s."SADDR", s."SERIAL#"
from v$session s
where s."SID" = '1184';
--kill会话进程
SQL> alter system kill session '1184,10472' immediate;
--将如上会话kill后,便可正常删除临时文件
SQL> alter tablespace temp drop tempfile '/u01/app/oracle/oradata/orcl/temp01.dbf';
Tablespace altered.
参考文档:https://blog.csdn.net/forever_river/article/details/61619769
标签:TEMP,dbf,app,01258,orcl,oracle,临时文件,u01,ORA
From: https://blog.51cto.com/u_12991611/6361634