Oracle 数据库 临时表空间文件(TEMP01.DBF)太大, 替换的方式缩小
2022/6/30 2:49:51
本文主要是介绍Oracle 数据库 临时表空间文件(TEMP01.DBF)太大, 替换的方式缩小,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
建议在数据库于未使用时操作
1 --查看临时表空间和其包含的文件 2 select d.file_name, d.file_id, d.tablespace_name, d.bytes from dba_temp_files d; 3 4 --创建新的临时表空间 5 create temporary tablespace temp02 tempfile 'C:\ORACLE\ORADATA\ORACLE\temp03.dbf' size 512M; 6 --把新建的临时表空间却换成数据库的默认临时表空间 7 alter database default temporary tablespace temp02; 8 --确认目前数据库的默认临时表空间 9 select * from database_properties where property_name='DEFAULT_TEMP_TABLESPACE'; 10 11 --在删除temp临时表空间之前,先把运行在temp临时表空间的sql语句kill掉,不然旧文件可能还会在使用中,或者在空载状态操作 12 --这样的sql语句多为排序的语句 13 select a.username,a.sid,a.serial#,a.tablespace,a.sql_text,'alter system kill session '''||a.sid||','||a.serial#||''';' "alter kill" from( 14 select se.username,se.sid,se.serial#,su.tablespace,s.sql_text 15 from v$sort_usage su,v$session se,v$sql s 16 where su.session_addr=se.saddr and s.hash_value=su.sqlhash and s.address=su.sqladdr -- and tablespace='TEMP' 17 group by se.username,se.sid,se.serial#,su.tablespace,s.sql_text 18 ) a 19 20 -- (假如某一条运行的sql语句的SID为524,serial#为778) 21 --alter system kill session '524,778'; 22 23 --替换掉原来的大文件,然后再改回默认临时空间 24 alter database tempfile 'C:\ORACLE\ORADATA\ORACLE\TEMP01.DBF' drop; 25 alter tablespace temp add tempfile 'C:\ORACLE\ORADATA\ORACLE\TEMP01.DBF' size 1024M reuse autoextend on next 100M; 26 alter database default temporary tablespace temp; 27 28 ---在删掉 新建的临时空间和文件 也可以不用改回去,直接删掉旧的,但是磁盘上的文件可能还在且无法删除!!! 29 drop tablespace temp including contents and datafiles;
PS: 我直接删除旧临时空间和文件
drop tablespace temp including contents and datafiles;
结果文件在磁盘上任何操作都提示无权限.....(也可能重启后就能删了?)
sql删掉的文件不一定会删掉磁盘上的文件!
这篇关于Oracle 数据库 临时表空间文件(TEMP01.DBF)太大, 替换的方式缩小的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-28pytorch imagefolder
- 2024-03-28如何使用web of science
- 2024-03-28Pandas error: AttributeError - 'new_block' not found
- 2024-03-28typeerror: cannot convert expression to float
- 2024-03-28yuzu msvcp140_atomic_wait.dll
- 2024-03-28pthread_mutex_unlock
- 2024-03-28create ami
- 2024-03-28conda install langchain
- 2024-03-28pycharm no interpreter
- 2024-03-28Elasticsearch - kibana画图