--查询用户缺省临时表空间
SQL> select username,temporary_tablespace from dba_users;
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
MGMT_VIEW TEMP
SYS TEMP
SYSTEM TEMP
DBSNMP TEMP
SYSMAN TEMP
SCOTT TEMP
HR TEMP
OUTLN TEMP
MDSYS TEMP
ORDSYS TEMP
EXFSYS TEMP
DMSYS TEMP
WMSYS TEMP
CTXSYS TEMP
ANONYMOUS TEMP
XDB TEMP
ORDPLUGINS TEMP
SI_INFORMTN_SCHEMA TEMP
OLAPSYS TEMP
TSMSYS TEMP
BI TEMP
PM TEMP
MDDATA TEMP
IX TEMP
SH TEMP
DIP TEMP
OE TEMP
27 rows selected.
--创建新的临时表空间
SQL> create temporary tablespace temp2 tempfile '/u02/temp1.dbf' size 10M;
Tablespace created.
--需要的话
--alter tablespace temp add tempfile '/u02/temp2.dbf' 10M;
--进行切换
SQL> alter database default temporary tablespace temp2 ;
Database altered.
--查询是否成功切换
SQL> select username,temporary_tablespace from dba_users;
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
MGMT_VIEW TEMP2
SYS TEMP2
SYSTEM TEMP2
DBSNMP TEMP2
SYSMAN TEMP2
SCOTT TEMP2
HR TEMP2
OUTLN TEMP2
MDSYS TEMP2
ORDSYS TEMP2
EXFSYS TEMP2
DMSYS TEMP2
WMSYS TEMP2
CTXSYS TEMP2
ANONYMOUS TEMP2
XDB TEMP2
ORDPLUGINS TEMP2
SI_INFORMTN_SCHEMA TEMP2
OLAPSYS TEMP2
TSMSYS TEMP2
BI TEMP2
PM TEMP2
MDDATA TEMP2
IX TEMP2
SH TEMP2
DIP TEMP2
OE TEMP2
27 rows selected.
方式1:重启数据库
SQL>alter tablespace temp increase 1;
SQL>alter tablespace temp increase 0;
方式3:sid,
serial#,
sql_address,
machine,
program,
tablespace,
segtype,
contents
FROM v$session se,
v$sort_usage su
WHERE se.saddr=su.session_addr
SQL> select ts#, name from sys.ts$ ;
TS# NAME
---------- --------------------
0 SYSTEM
1 UNDOTBS1
2 SYSAUX
3 TEMP
4 USERS
5 UNDOTBS2
6 EXAMPLE
7 TSS
8 TEMP2
SQL> alter session set events 'immediate trace name DROP_SEGMENTS level 4' ;
Session altered.
SELECT (F.TABLESPACE_NAME) "tablesacpe name",
D.TOT_GROOTTE_MB "tablespace size(M)",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "have used(M)",
(((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') "using rate",
F.TOTAL_BYTES "free space(M)",
F.MAX_BYTES "max block(M)"
FROM (SELECT TABLESPACE_NAME,
((BYTES) / (1024 * 1024), 2) TOTAL_BYTES,
((BYTES) / (1024 * 1024), 2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
((DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 4 DESC