oracle的臨時表空間寫滿磁盤空間解決改問題的步驟
oracle的臨時表空間寫滿磁盤空間,解決改問題的具體步驟,以下的操作是用數(shù)據(jù)庫的sys超級用戶操作
剛開始打算把臨時表空間的數(shù)據(jù)文件重新縮小就好了
執(zhí)行:
SQL> alter database tempfile
2 '/oracle/oms/oradata/temp/temp01.dbf' resize 10240M;
數(shù)據(jù)庫報錯,重新設置的空間大小不能滿足需要。
看來需要重新建立新的臨時表空間替換當前的表空間了
1、首先查看當前的數(shù)據(jù)庫默認表空間:
SQL>select * from database_properties
where property_name='DEFAULT_TEMP_TABLESPACE';
確認當前的臨時表空間為TEMP
2、查看目前臨時表空間的大?。?/p>
SQL>select file_name,tablespace_name,bytes/1024/1024 "MB",autoextensible from dba_temp_files;
3、創(chuàng)建新的臨時表空間:(先在其他的磁盤空間借用一下空間)
SQL> create temporary tablespace temp02
2 tempfile '/oracle/oms/oradata/undo/temp02.dbf'
3 size 512M;
4、把新建的臨時表空間卻換成數(shù)據(jù)庫的默認臨時表空間
SQL> alter database default temporary tablespace temp02;
5、確認目前數(shù)據(jù)庫的默認臨時表空間
SQL>select * from database_properties
where property_name='DEFAULT_TEMP_TABLESPACE';
6、在刪除temp臨時表空間之前,先把運行在temp臨時表空間的sql語句kill掉,這樣的sql語句多為排序的語句
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.hashvalue=su.sqlhash
and s.address=su.sqladdr
order by se.username,se.sid;
查詢出來之后,kill掉這些sql語句:
SQL>alter system kill session '524,778'; (假如某一條運行的sql語句的SID為524,serial#為778)
確認在temp臨時表空間中沒有運行的sql語句之后,則可以刪除temp臨時表空間數(shù)據(jù)文件了
7、刪除temp臨時表空間
SQL> drop tablespace temp including contents and datafiles;
這樣很快就可以刪除了臨時表空間的數(shù)據(jù)文件
8、現(xiàn)在temp02臨時表空間占據(jù)了別人的磁盤空間,需要重新把臨時表空間建立在原來的位置,重新建立temp臨時表空間
SQL> create temporary tablespace temp
2 tempfile '/oracle/oms/oradata/temp/temp01.dbf'
3 size 512M autoextend on maxsize 15G;
新建一個512M的自動擴展臨時表空間,***的擴展為15G。
查看新建的temp臨時表空間是否正確:
SQL>select file_name,tablespace_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;
9、把新建的temp臨時表空間卻換成數(shù)據(jù)庫的默認臨時表空間
SQL> alter database default temporary tablespace temp;
10、確認目前數(shù)據(jù)庫的默認臨時表空間
SQL>select * from database_properties
where property_name='DEFAULT_TEMP_TABLESPACE';
確認temp為當前的數(shù)據(jù)庫默認表空間
11、目前把原來的temp臨時表空間變成了512M,把剩余的磁盤空間空了出來,temp02臨時表空間就沒有用了,刪除temp02臨時表空間
SQL> drop tablespace temp02 including contents and datafiles;
通過上文中介紹的方法,關于oracle的臨時表空間寫滿磁盤空間的問題就能夠輕松解決了,同時也避免了oracle的臨時表空間寫滿磁盤空間帶來的麻煩,希望大家通過上文的學習都能夠從中有所收獲。