欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解如何刪除Oracle數(shù)據(jù)庫(kù)臨時(shí)表空間

 更新時(shí)間:2024年03月11日 10:09:52   作者:lzyever  
因生產(chǎn)環(huán)境磁盤(pán)空間不足,影響了業(yè)務(wù),短時(shí)間內(nèi)無(wú)法擴(kuò)容磁盤(pán),經(jīng)過(guò)排查發(fā)現(xiàn),可以釋放temp臨時(shí)表空間來(lái)臨時(shí)釋放部分空間,本文記錄了如何釋放臨時(shí)表空間的詳細(xì)操作步驟,需要的朋友可以參考下

前言

因生產(chǎn)環(huán)境磁盤(pán)空間不足,影響了業(yè)務(wù),短時(shí)間內(nèi)無(wú)法擴(kuò)容磁盤(pán),經(jīng)過(guò)排查發(fā)現(xiàn),可以釋放temp臨時(shí)表空間來(lái)臨時(shí)釋放部分空間。

本文記錄了如何釋放臨時(shí)表空間的詳細(xì)操作步驟。

1、查看舊的臨時(shí)表空間

首先查看舊的臨時(shí)表空間的空間占用情況

SQL>select tablespace_name,tablespace_size/1024/1024, allocated_space/1024/1024,free_space/1024/1024 from dba_temp_free_space;
    TABLESPACE_NAME      TABLESPACE_SIZE/1024/1024 ALLOCATED_SPACE/1024/1024 FREE_SPACE/1024/1024
    -------------------- ------------------------- ------------------------- --------------------
    TEMP  

                               23069                     23069                23067

2、新建temp表空間

創(chuàng)建新的臨時(shí)表空間,用于替換舊的臨時(shí)表空間

SQL>create temporary tablespace temp1 tempfile ‘+DATA' size 100m autoextend on;  
Tablespace created.  

3、修改默認(rèn)臨時(shí)表空間

將新的臨時(shí)表空間設(shè)置為默認(rèn)的臨時(shí)表空間

SQL>alter database default temporary tablespace temp1;  
Database altered. 

4、查看新建的臨時(shí)表空間使用情況

新的臨時(shí)表空間被設(shè)置為默認(rèn)臨時(shí)表空間后,新的臨時(shí)數(shù)據(jù)會(huì)寫(xiě)到新的臨時(shí)表空間中,下面查看新建的臨時(shí)標(biāo)快的空間占用情況

SQL>select tablespace_name,tablespace_size/1024/1024 total, allocated_space/1024/1024 allocated ,free_space/1024/1024 free from dba_temp_free_space;

tablespace_name       total                       allocated                   free
-------------------- ------------------------- ------------------------- --------------------
TEMP                     23069                     23069                23067
TEMP1                    100                         3                   99

5、查看臨時(shí)表空間使用情況

5.1、查看誰(shuí)在使用臨時(shí)表空間

下面的SQL查詢(xún)哪些會(huì)話在占用舊的臨時(shí)表空間

SQL>Col PROGRAM for a20
SQL>Col MACHINE for a20
SQL>col username for a15
SQL>SELECT se.username,
sid,
serial#,
sql_address,
machine,
program,
tablespace,
segtype,
contents
FROM v$session se,v$sort_usage su
WHERE se.saddr=su.session_addr order by 7,1;

5.2、然后查看用戶(hù)的狀態(tài)是active還是inactive,如果是inactive,直接kill即可

如果舊的臨時(shí)表空間的會(huì)話是active,需要謹(jǐn)慎,不能直接kill,需要等待會(huì)話消失或者變成inactive狀態(tài)。如果是inactive狀態(tài),可以直接kill會(huì)話。

SQL>select * from v$session where sid=‘1042';  
SQL>alter system kill session ‘1042,48682';

5.3、查看臨時(shí)表空間上正在執(zhí)行哪些SQL

上面的SQL查看哪些會(huì)話運(yùn)行在舊的臨時(shí)表空間, 下面的SQL將查詢(xún)active會(huì)話中,正在執(zhí)行的SQL語(yǔ)句。以此來(lái)判斷是否是關(guān)鍵的事物。

SQL>Col tablespace name for a20  
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;

6、確定舊的臨時(shí)表空間沒(méi)有在被使用,直接刪除即可

通過(guò)上面的兩個(gè)SQL語(yǔ)句確認(rèn)舊的臨時(shí)表空間上沒(méi)有會(huì)話和事物之后,就可以刪除舊的臨時(shí)表空間了。

SQL>drop tablespace temp including contents and datafiles;

到此這篇關(guān)于詳解如何刪除Oracle數(shù)據(jù)庫(kù)臨時(shí)表空間的文章就介紹到這了,更多相關(guān)刪除Oracle臨時(shí)表空間內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論