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、擴展臨時表空間:
方法一稳强、增大臨時文件大谐≈佟:
SQL> alter database tempfile ‘/u01/app/oracle/oradata/orcl/temp01.dbf’ resize 100m;
方法二、將臨時數(shù)據(jù)文件設為自動擴展:
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;