oracle表空單清理常用代碼段整理
sqlplus system/manager@topprod
SQL>@q_tbsFREE
2.查詢temp使用方法:
sqlplus system/manager@topprod
SQL>SELECT
d.tablespace_name tablespace_name
, d.status tablespace_status
, NVL(a.bytes, 0) tablespace_size
, NVL(t.bytes, 0) used
, TRUNC(NVL(t.bytes / a.bytes * 100, 0)) used_pct
, NVL(s.current_users, 0) current_users
FROM
sys.dba_tablespaces d
, ( select tablespace_name, sum(bytes) bytes
from dba_temp_files
group by tablespace_name
) a
, ( select tablespace_name, sum(bytes_cached) bytes
from v$temp_extent_pool
group by tablespace_name
) t
, v$sort_segment s
WHERE
d.tablespace_name = a.tablespace_name(+)
AND d.tablespace_name = t.tablespace_name(+)
AND d.tablespace_name = s.tablespace_name(+)
AND d.extent_management like 'LOCAL'
AND d.contents like 'TEMPORARY';
2.清理TEMP臨時(shí)表空間:(在無(wú)用戶連接的狀況下操作,最好在清理之前重啟一下數(shù)據(jù)庫(kù))
#重啟數(shù)據(jù)庫(kù)
sqlplus '/as sysdba'
SQL>shutdown immediate
SQL>startup
#創(chuàng)建一個(gè)臨時(shí)表空間temp02,用作臨時(shí)替換
SQL>create temporary tablespace temp02 tempfile '/u2/oradb/oradata/topprod/temp02.dbf' size 10M autoextend on next 10M;
#將系統(tǒng)臨時(shí)表空間指向temp02
SQL>alter database default temporary tablespace temp02;
#刪除原來(lái)的臨時(shí)表空間temp
SQL>drop tablespace temp including contents and datafiles;
#創(chuàng)建新的臨時(shí)表空間temp
SQL>create temporary tablespace temp tempfile '/u2/oradb/oradata/topprod/temp01.dbf' size 4096M autoextend on next 100M;
#將系統(tǒng)臨時(shí)表空間指回temp
SQL>alter database default temporary tablespace temp;
#刪除臨時(shí)表空間temp02
SQL>drop tablespace temp02 including contents and datafiles;
3.清理UNDO表空間:(在無(wú)用戶連接的狀況下操作,最好在清理之前重啟一下數(shù)據(jù)庫(kù))
#重啟數(shù)據(jù)庫(kù)
sqlplus '/as sysdba'
SQL>shutdown immediate
SQL>startup
#創(chuàng)建一個(gè)UNDO表空間undotbs2,用作臨時(shí)替換
SQL>create undo tablespace undotbs2 datafile '/u2/oradb/oradata/topprod/undotbs02.dbf' size 10M autoextend on next 10M;
#將系統(tǒng)UNDO表空間指向undotbs2
SQL>alter system set undo_tablespace=undotbs2 scope=both;
#確保所有在UNDOTBS1的undo segment都已offline
SQL> select SEGMENT_NAME ,STATUS ,TABLESPACE_NAME from dba_rollback_segs;
#刪除原來(lái)的UNDO表空間undotbs1
SQL>drop tablespace undotbs1 including contents and datafiles;
#創(chuàng)建新的臨時(shí)表空間undotbs1
SQL>create undo tablespace undotbs1 datafile '/u2/oradb/oradata/topprod/undotbs01.dbf' size 4096M;
#將系統(tǒng)UNDO表空間指回undotbs1
SQL>alter system set undo_tablespace=undotbs1 scope=both;
#刪除UNDO表空間undotbs2
SQL>drop tablespace undotbs2 including contents and datafiles;
3.清理TEMPTABS表空間:
#刪除TEMPTABS表空間
SQL>drop tablespace temptabs including contents and datafiles;
#創(chuàng)建TEMPTABS表空間
SQL>create tablespace temptabs datafile '/u2/oradb/oradata/topprod/temptabs.dbf' size 4096M autoextend on next 100M;
或者刪除表
[code]
select 'drop table '||segment_name ||';' from dba_segments where tablespace_name='TEMPTABS' and segment_name like 'TT%' and segment_name not like '%_FILE';
4.增加系統(tǒng)表空間:
alter tablespace SYSTEM add datafile '/u2/oradb/oradata/topprod/system02.dbf' size 2000M autoextend on next 10M;
alter tablespace SYSAUX add datafile '/u2/oradb/oradata/topprod/sysaux02.dbf' size 2000M autoextend on next 10M;
相關(guān)文章
Oracle11g r2 卸載干凈重裝的詳細(xì)教程(親測(cè)有效已重裝過(guò))
Oracle 的安裝和卸載相較于其他 mysql 要麻煩些,小編特此分享一篇教程關(guān)于Oracle11g 徹底卸載干凈并重新安裝,有需要的朋友可以參考下本文2021-06-06
Oracle 要慌了!華為終于開(kāi)源了自家的 Huawei JDK——畢昇 JDK!
畢昇 JDK 是華為內(nèi)部 OpenJDK 定制版 Huawei JDK 的開(kāi)源版本,是一個(gè)高性能、可用于生產(chǎn)環(huán)境的 OpenJDK 發(fā)行版,感興趣的朋友跟隨小編一起看看吧2020-12-12
Oracle 如何規(guī)范清理v$archived_log記錄實(shí)例詳解
這篇文章主要介紹了Oracle 如何規(guī)范清理v$archived_log記錄實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2017-05-05
Oracle使用RMAN進(jìn)行數(shù)據(jù)庫(kù)恢復(fù)的實(shí)現(xiàn)步驟
使用 RMAN(Recovery Manager)恢復(fù) Oracle 數(shù)據(jù)庫(kù)是確保數(shù)據(jù)在災(zāi)難情況下能夠得到恢復(fù)的關(guān)鍵步驟,以下是詳細(xì)的指導(dǎo)和代碼示例,展示如何使用 RMAN 進(jìn)行數(shù)據(jù)庫(kù)恢復(fù),需要的朋友可以參考下2024-09-09
Oracle單行函數(shù)(字符,數(shù)值,日期,轉(zhuǎn)換)
這篇文章主要介紹了Oracle單行函數(shù)(字符,數(shù)值,日期,轉(zhuǎn)換),本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-07-07
簡(jiǎn)單實(shí)例解釋Oracle分頁(yè)查詢
這篇文章主要給大家介紹了關(guān)于Oracle分頁(yè)查詢的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Oracle具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11
直接拷貝數(shù)據(jù)文件實(shí)現(xiàn)Oracle數(shù)據(jù)遷移
Oracle 數(shù)據(jù)遷移是比較麻煩的,對(duì)菜鳥(niǎo)來(lái)說(shuō)更是如此。最近由于更換服務(wù)器,需要將Oracle遷移到另外一臺(tái)機(jī)器,在兩個(gè)服務(wù)器環(huán)境相同,以及 Oracle版本相同的前提下,通過(guò)直接拷貝數(shù)據(jù)文件到新服務(wù)器,就可以直接遷移成功。這里記錄一下遷移步驟。需要的朋友可以參考。2017-01-01
安裝Oracle時(shí)出現(xiàn)環(huán)境變量Path的值大于1023的解決辦法
這篇文章主要介紹了安裝Oracle時(shí)出現(xiàn)環(huán)境變量Path的值大于1023的解決辦法,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起看看吧2016-12-12

