對ORACLE的TEMP和UNDO空間的操作集合

2021-06-20 13:44:03 字數 2038 閱讀 3526

1) 查詢temp表空間大小:

select temp_used.tablespace_name, total - used as "free", total as "total", round(nvl(total - used, 0) * 100 / total, 3) "free percent"

from (select tablespace_name, sum(bytes_used)/1024/1024 used from gv$temp_space_header group by tablespace_name) temp_used,

(select tablespace_name, sum(bytes)/1024/1024 total from dba_temp_files group by tablespace_name) temp_total

where temp_used.tablespace_name = temp_total.tablespace_name;

2) 擴充套件temp表空間,增加資料檔案。

alter tablespace temp add tempfile  '/data2/ras/temp02.dbf' size 32000m;

3) 如果temp過滿,要清空,可以採用重建的方法。

create temporary tablespace "temp1" tempfile  'e:\oracledata\temp02.dbf' size 15000m reuse

autoextend on next  2000k maxsize  15000m extent management local uniform size 1024k;

alter database default temporary tablespace "temp1"

drop tablespace temp including contents and datafiles; 

4)查詢temp資料檔案位置,每個資料檔案大小及是否自動擴充套件等。

select a.file_name,a.bytes/1024/1024 "mb",a.autoextensible,a.tablespace_name , a.* from dba_temp_files a ; 或者

select * from v$tempfile;

5) 擴充套件redo表空間,增加資料檔案。

alter tablespace undotbs1 add datafile '/data2/ras/undo02.dbf' size 32000m reuse;

6)  查詢redo表空間大小及使用情況:

select upper(f.tablespace_name) "表空間名", d.tot_grootte_mb "表空間大小(m)", d.tot_grootte_mb-f.total_bytes "已使用空間(m)",  to_char(round((d.tot_grootte_mb-f.total_bytes)/d.tot_grootte_mb*100,2),'990.99') "使用百分比", f.total_bytes "空閒空間(m)"   from (select tablespace_name,  round(sum(bytes)/1024/1024) total_bytes,    round(max(bytes)/(1024*1024),2) max_bytes

from sys.dba_free_space group by tablespace_name) f,

(select dd.tablespace_name,  round(sum(bytes)/1024/1024) tot_grootte_mb   from sys.dba_data_files dd

group by dd.tablespace_name) d

where d.tablespace_name=f.tablespace_name

order by 2 desc;

7) 查詢redo的資料檔案位置和查詢資料庫的資料檔案是一樣的。

select * from dba_data_files where tablespace_name = 'undotbs1'



我對異常的理解 temp2

try的英文意思就是嘗試 例如 try to do sth.意思就是說嘗試著做一些事情,你試著做的時候可能會成功,也可能不成功,成功了最好,但是不成功也沒有事情的,因為畢竟是嘗試嘛.我覺得老外在c 裡面的異常中使用try這個關鍵字很形象,try這個try塊的意思就是說你試著做大括號裡面的事情,如果出...

temp和undo常用的查詢命令

1.檢視消耗臨時表空間比較大的sql select se.username,se.sid,su.extents,su.blocks to number rtrim p.value as space,tablespace,segtype,sql text from v sort usage su,v ...

如何處理Oracle中TEMP表空間滿的問題

正常來說,在完成select語句 create index等一些使用temp表空間的排序操作後,oracle是會自動釋放掉臨時段a的。但有些有侯我們則會遇到臨時段沒有被釋放,temp表空間幾乎 滿的狀況,甚至是我們重啟了資料庫仍沒有解決問題。這個問題在論壇中也常被問到,下面我總結一下,給出幾種處理方...