oracle臨時(shí)表空間的作用與創(chuàng)建及相關(guān)操作詳解
1.1 臨時(shí)表空間作用
用來(lái)存放用戶(hù)的臨時(shí)數(shù)據(jù),臨時(shí)數(shù)據(jù)就是在需要時(shí)被覆蓋,關(guān)閉數(shù)據(jù)庫(kù)后自動(dòng)刪除,其中不能存放永久臨時(shí)性數(shù)據(jù)。
如:
當(dāng)用戶(hù)對(duì)大量數(shù)據(jù)進(jìn)行排序時(shí),排序在PGA中進(jìn)行,若數(shù)據(jù)過(guò)多,導(dǎo)致內(nèi)存不足,oracle會(huì)把需要排序的數(shù)據(jù)分為多份,每次取一份在PGA中排序,其余部分放在臨時(shí)表空間,直至所有數(shù)據(jù)排序完成,不過(guò)臨時(shí)表空間在硬盤(pán)上,數(shù)據(jù)交換降低性能
1.2 臨時(shí)表空間和臨時(shí)表空間組
臨時(shí)表空間組是由一組臨時(shí)表空間組成的組,臨時(shí)表空間組和臨時(shí)表空間不能同名。臨時(shí)表空間組不能顯式地被創(chuàng)建和刪除;當(dāng)把第一個(gè)臨時(shí)表空間分配某個(gè)臨時(shí)表空間組時(shí),會(huì)自動(dòng)創(chuàng)建臨時(shí)表空間組;當(dāng)把臨時(shí)表空間組內(nèi)最后一個(gè)臨時(shí)表空間刪除時(shí),會(huì)自動(dòng)刪除臨時(shí)表空間組;
1.3 臨時(shí)表空間操作
(1) 查看表空間
select * from v$tablespace;
(2) 查看表空間詳細(xì)信息
select * from dba_tablespaces;
CONTENTS字段值為T(mén)EMPORARY,即臨時(shí)表空間
(3) 查看除臨時(shí)表空間外 表空間對(duì)應(yīng)的數(shù)據(jù)文件
select * from dba_data_files;
(4) 查看臨時(shí)表空間對(duì)應(yīng)的數(shù)據(jù)文件
select * from dba_temp_files;
select * from v$tempfile;
(5) 查看臨時(shí)表空間組信息
select * from dba_tablespace_groups;
(6) 查看默認(rèn)的臨時(shí)表空間
select * from database_properties where PROPERTY_NAME='DEFAULT_TEMP_TABLESPACE';
1.4 創(chuàng)建臨時(shí)表空間
(1) 創(chuàng)建不屬于組的臨時(shí)表空間
create temporary tablespace temp2 tempfile 'D:\software\oracle\oradata\orcl\temp2a.dbf' size 10m autoextend on ;
(2) 屬于組的臨時(shí)表空間
create temporary tablespace temp3 tempfile 'D:\software\oracle\oradata\orcl\temp3a.dbf' size 10m autoextend on tablespace group temp_group ;
(2) 臨時(shí)表空間加入或移除臨時(shí)表空間組
把temp2加入到temp_group 中
alter tablespace temp2 tablespace group temp_group;
把temp2移除emp_group
alter tablespace temp2 tablespace group '';
(3)給臨時(shí)表空間添加一個(gè)臨時(shí)文件
alter tablespace temp2 add tempfile 'D:\software\oracle\oradata\orcl\temp2b.dbf' size 10m autoextend on;
(4)修改系統(tǒng)默認(rèn)的臨時(shí)表空間
修改為一個(gè)組
alter database default temporary tablespace temp_group ;
修改為一個(gè)臨時(shí)表空間
alter database default temporary tablespace temp2;
補(bǔ)充:對(duì)臨時(shí)文件進(jìn)行刪除
alter tablespace temp drop tempfile '/m/oracle/oradata4/temp05.dbf'; alter tablespace temp drop tempfile '/m/oracle/oradata5/temp06.dbf'; alter tablespace temp drop tempfile '/m/oracle/oradata5/temp07.dbf'; alter tablespace temp add tempfile '/m/oracle/oradata4/temp05.dbf' size 1G reuse; alter tablespace temp add tempfile '/m/oracle/oradata5/temp06.dbf' size 1G reuse; alter tablespace temp add tempfile '/m/oracle/oradata5/temp07.dbf' size 1G reuse;
刪除過(guò)程:
SQL> alter database tempfile '/u01/app/oracle/oradata/temp2' drop including datafiles;
alter database tempfile '/u01/app/oracle/oradata/temp2' drop including datafiles
*
ERROR at line 1:
ORA-25152: TEMPFILE cannot be dropped at this time
通過(guò)查看官方針對(duì)ORA-25152的描述信息,發(fā)現(xiàn)如下:
ORA-25152: TEMPFILE cannot be dropped at this time
Cause: An attempt was made to drop a TEMPFILE being used by online users
Action: The TEMPFILE has been taken offline. Try again, later
可能是臨時(shí)表空間被占用,執(zhí)行以下腳本,查詢(xún)出占用臨時(shí)表空間的會(huì)話(huà)信息,使用alter system kill命令殺掉會(huì)話(huà)進(jìn)程,即可解決問(wèn)題。
也可以等待一段時(shí)間之后,對(duì)臨時(shí)表空間臨時(shí)文件進(jìn)行刪除即可 。
總結(jié)
到此這篇關(guān)于oracle臨時(shí)表空間的作用與創(chuàng)建及相關(guān)操作的文章就介紹到這了,更多相關(guān)oracle臨時(shí)表空間創(chuàng)建內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Oracle管道函數(shù)pipelined?function的用法小結(jié)
這篇文章主要介紹了Oracle管道函數(shù)pipelined?function的用法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-07-07Oracle數(shù)據(jù)庫(kù)存儲(chǔ)過(guò)程的調(diào)試過(guò)程
oracle如果存儲(chǔ)過(guò)程比較復(fù)雜,我們要定位到錯(cuò)誤就比較困難,那么我們就可以用存儲(chǔ)過(guò)程的調(diào)試功能,下面這篇文章主要給大家介紹了關(guān)于Oracle數(shù)據(jù)庫(kù)存儲(chǔ)過(guò)程調(diào)試的相關(guān)資料,需要的朋友可以參考下2022-07-07Oracle數(shù)據(jù)庫(kù)中建立索引的基本方法講解
這篇文章主要介紹了Oracle數(shù)據(jù)庫(kù)中建立索引的基本方法,包括對(duì)性能方面進(jìn)行衡量而給出的一些索引的設(shè)計(jì)和使用建議,需要的朋友可以參考下2016-01-01簡(jiǎn)單說(shuō)明Oracle數(shù)據(jù)庫(kù)中對(duì)死鎖的查詢(xún)及解決方法
這篇文章主要介紹了Oracle數(shù)據(jù)庫(kù)中對(duì)死鎖的查詢(xún)及解決方法,文中用兩個(gè)表創(chuàng)造死鎖的簡(jiǎn)單例子來(lái)說(shuō)明對(duì)死鎖的撤銷(xiāo)方法,需要的朋友可以參考下2016-01-01oracle獲取當(dāng)前用戶(hù)表、字段等詳細(xì)信息SQL
這篇文章主要介紹了oracle獲取當(dāng)前用戶(hù)表、字段等詳細(xì)信息SQL,需要的朋友可以參考下2014-07-07Oracle DATABASE LINK(DBLINK)創(chuàng)建與刪除方法
這篇文章主要介紹了Oracle DATABASE LINK(DBLINK)創(chuàng)建與刪除方法,需要的朋友可以參考下2016-02-02Oracle 11g服務(wù)器與客戶(hù)端卸載、安裝全過(guò)程
Oracle 11g服務(wù)器與客戶(hù)端的完全卸載方式與前些版本有了改變,下面是具體的操作過(guò)程,感興趣的朋友可以參考下哈2013-06-06