临时表空间过大解决方法
admin
2023-04-21 12:04:47
0


临时表空间过大解决方法



解决临时表空间过大有两种方法,方法一增加临时表空间的大小,方法二重建临时表空间,解决临时表空间过大的问题。


方案一:增加临时表空间的大小
--1.临时表空间的使用情况
SELECT D.tablespace_name,
       SPACE "SUM_SPACE(M)",       
       blocks "SUM_BLOCKS",      
       used_space "USED_SPACE(M)",       
       Round(Nvl(used_space, 0) / SPACE * 100, 2) "USED_RATE(%)",       
       SPACE - used_space "FREE_SPACE(M)"
  FROM (SELECT tablespace_name,              
               Round(SUM(bytes) / (1024 * 1024), 2) SPACE,               
               SUM(blocks) BLOCKS        
          FROM dba_temp_files        
         GROUP BY tablespace_name) D,       
       (SELECT tablespace,               
               Round(SUM(blocks * 8192) / (1024 * 1024), 2) USED_SPACE        
          FROM v$sort_usage        
         GROUP BY tablespace) F
 WHERE D.tablespace_name = F.tablespace(+)      
   AND D.tablespace_name like 'TEMP%';


--查看临时表空间的总大小和最大扩展大小(能看到数据文件)
select file_name,
       tablespace_name,
       bytes / 1024 / 1024 MB,
       autoextensible,
       maxbytes / 1024 / 1024 MAX_MB
  from dba_temp_files;

--增加临时表空间的大小
alter tablespace temp1 add tempfile '/data/prod/proddata/temp013.dbf' size 4G;
alter tablespace temp2 add tempfile '/data/prod/proddata/temp024.dbf' size 4G;

--方案二:重建临时表空间,解决临时表空间过大的问题。

--0.查看目前默认的临时表空间
select *
  from database_properties
 where property_name = 'DEFAULT_TEMP_TABLESPACE';

--1.创建中转临时表空间
create temporary tablespace temp3 tempfile '/data/prod/proddata/temp31.dbf' size 4G tablespace group temp;
create temporary tablespace temp4 tempfile '/data/prod/proddata/temp41.dbf' size 4G tablespace group temp;

--2.删除原临时表空间组中的临时表空间
--2.1从默认临时表空间组temp中移除temp1和temp2;
ALTER TABLESPACE temp1 TABLESPACE GROUP '';
ALTER TABLESPACE temp2 TABLESPACE GROUP '';


--2.2删除临时表空间temp1和temp2
drop tablespace temp1 including contents and datafiles;
drop tablespace temp2 including contents and datafiles;

--2.3如果删除表空间的时候,hang住的话,可以使用下列语句,先把运行在temp临时表空间的sql语句kill掉,这样的sql语句多为排序的语句
Select se.username,
       se.sid,
       se.serial#,
       su.extents,
       su.blocks * to_number(rtrim(p.value)) as Space,
       tablespace,
       segtype,
       sql_text
  from v$sort_usage su, v$parameter p, v$session se, v$sql s
 where p.name = 'db_block_size'
   and su.session_addr = se.saddr
   and s.hash_value = su.sqlhash
   and s.address = su.sqladdr
 order by se.username, se.sid;

--2.4 kill相关进程
alter system kill session '584,23181';
alter system kill session '196,64972';
alter system kill session '262,19832';
alter system kill session '324,40273';
alter system kill session '326,38967';
alter system kill session '1266,54596';
 
or
--重启DB
--关闭应用-->关闭监听-->shutdown immediate
--startup-->启动监听-->执行以下操作后打开应用

--2.5 创建临时表空间,并加入临时表空间组temp
create temporary tablespace temp1 tempfile '/data/prod/proddata/temp11.dbf' size 4G tablespace group temp;
create temporary tablespace temp2 tempfile '/data/prod/proddata/temp21.dbf' size 4G tablespace group temp;

--2.6 给临时表空间组temp的成员temp1,temp2,temp3,temp4 各增加一个成员。
alter tablespace temp1 add tempfile '/data/prod/proddata/temp12.dbf' size 4G;
alter tablespace temp2 add tempfile '/data/prod/proddata/temp22.dbf' size 4G;
alter tablespace temp3 add tempfile '/data/prod/proddata/temp32.dbf' size 4G;
alter tablespace temp4 add tempfile '/data/prod/proddata/temp42.dbf' size 4G;

--2.7查看临时表空间组temp
select * from dba_tablespace_groups;

--3 临时表空间组仍然使用99.98%,
--3.1为每个临时表空间添加4G空间
alter tablespace temp1 add tempfile '/data/prod/proddata/temp13.dbf' size 4G;
alter tablespace temp2 add tempfile '/data/prod/proddata/temp23.dbf' size 4G;
alter tablespace temp3 add tempfile '/data/prod/proddata/temp33.dbf' size 4G;
alter tablespace temp4 add tempfile '/data/prod/proddata/temp43.dbf' size 4G;



相关内容

热门资讯

燃气发电与电池储能相结合,成为... 来源:市场资讯 (来源:i商周) 孟菲斯一座xAI数据中心的燃气轮机 人工智能的用电飙升,让数据中心...
景嘉微:JM11性能大幅提升,... 有投资者在互动平台向景嘉微提问:“董秘您好!关注到近期有用户反馈公司JM11显卡推出了适配windo...
原创 v... 影像的发展进一步推动,不少品牌推出了专业影像手机,拥有2亿像素摄像头、色彩还原摄像头、影像芯片、影像...
荣耀首款自研耳夹式耳机官宣即将... 快科技5月13日消息,日前,荣耀首席营销官关海涛宣布,荣耀全场景团队自研首款耳夹式耳机马上上市,并称...
谷歌推出Googlebooks... IT之家 5 月 13 日消息,2026 年 I/O 开发者大会下周(5 月 19~20 日)召开之...
自控所推动GNC专业智能化升级 来源:滚动播报 (来源:中国航空报) 本报讯 5月6日,航空工业自控所召开 GNC+AI关键技术研发...
华电电力申请数据库访问方法专利... 国家知识产权局信息显示,华电电力科学研究院有限公司申请一项名为“数据库访问方法、装置、设备及介质”的...
苏州率先打造数据流通利用新范式 数据,作为第五大生产要素 具有流动性强、非消耗性、非均质性等特点 苏州率先打造数据流通利用新范式 夯...
伊媒披露伊美新一轮谈判5个先决... 当地时间5月12日,据伊朗法尔斯通讯社援引知情人士消息报道,伊朗对与美国新一轮谈判提出的5个先决条件...
英国将向霍尔木兹海峡多国护航行... 当地时间12日,总台记者从英国国防部获悉,英国将向在霍尔木兹海峡执行任务的多国护航行动提供无人机、战...