1、檢視臨時表空間 (dba_temp_files檢視)(v_$tempfile檢視)
select tablespace_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;
方法二、將臨時資料檔案設為自動擴充套件:
SQL> alter database tempfile ‘/u01/app/oracle/oradata/orcl/temp01.dbf’ autoextend on next 5m maxsize unlimited;
方法三、向臨時表空間中新增資料檔案:
SQL> alter tablespace temp add tempfile ‘/u01/app/oracle/oradata/orcl/temp02.dbf’ size 100m;
4、建立臨時表空間:
SQL> create temporary tablespace temp1 tempfile ‘/u01/app/oracle/oradata/orcl/temp11.dbf’ size 10M;
5、更改系統的預設臨時表空間:
--查詢預設臨時表空間
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;
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
FROM GV_$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;
1、檢視臨時表空間 (dba_temp_files檢視)(v_$tempfile檢視)
select tablespace_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;
方法二、將臨時資料檔案設為自動擴充套件:
SQL> alter database tempfile ‘/u01/app/oracle/oradata/orcl/temp01.dbf’ autoextend on next 5m maxsize unlimited;
方法三、向臨時表空間中新增資料檔案:
SQL> alter tablespace temp add tempfile ‘/u01/app/oracle/oradata/orcl/temp02.dbf’ size 100m;
4、建立臨時表空間:
SQL> create temporary tablespace temp1 tempfile ‘/u01/app/oracle/oradata/orcl/temp11.dbf’ size 10M;
5、更改系統的預設臨時表空間:
--查詢預設臨時表空間
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;
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
FROM GV_$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;