oracle操作臨時表空間

1、查看臨時表空間 (dba_temp_files視圖)(v_$tempfile視圖)

selectt ablespace_name,file_name,bytes/1024/1024 file_size,autoextensible from dba_temp_files;

select?status,enabled, name, bytes/1024/1024 file_size from v_$tempfile;--sys用戶查看

2、縮小臨時表空間大小

alter database tempfile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\TELEMT\TEMP01.DBF' resize 100M;

3、擴展臨時表空間:

方法一、增大臨時文件大?。?/p>

SQL> alter database tempfile ‘/u01/app/oracle/oradata/orcl/temp01.dbf’ resize 100m;

方法二、將臨時數(shù)據(jù)文件設(shè)為自動擴展:

SQL> alter database tempfile ‘/u01/app/oracle/oradata/orcl/temp01.dbf’ autoextend on next 5m maxsize unlimited;

方法三、向臨時表空間中添加數(shù)據(jù)文件:

SQL> alter tablespace temp add tempfile ‘/u01/app/oracle/oradata/orcl/temp02.dbf’ size 100m;

4、創(chuàng)建臨時表空間:

SQL> create temporary tablespace temp1 tempfile ‘/u01/app/oracle/oradata/orcl/temp11.dbf’ size 10M;

5、更改系統(tǒng)的默認臨時表空間:

--查詢默認臨時表空間

select* from database_properties where property_name='DEFAULT_TEMP_TABLESPACE';

--修改默認臨時表空間

alter database default temporary tablespace temp1;

所有用戶的默認臨時表空間都將切換為新的臨時表空間:

select username,temporary_tablespace,default_ from dba_users;

--更改某一用戶的臨時表空間:

alter user scott temporary tablespace temp;

6、刪除臨時表空間

刪除臨時表空間的一個數(shù)據(jù)文件:

SQL> alter database tempfile ‘/u01/app/oracle/oradata/orcl/temp02.dbf’ drop;

刪除臨時表空間(徹底刪除):

SQL> drop tablespace temp1 including contents and datafiles cascade constraints;

7、查看臨時表空間的使用情況(GV_$TEMP_SPACE_HEADER視圖必須在sys用戶下才能查詢)

GV_$TEMP_SPACE_HEADER視圖記錄了臨時表空間的使用大小與未使用的大小

dba_temp_files視圖的bytes字段記錄的是臨時表空間的總大小

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

FROMGV_$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

ORDER BY B.TABLESPACE, B.SEGFILE#, B.SEGBLK#, B.BLOCKS;

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容