20160822Oracle 11g Temporary Tablespace
[20160822]Oracle 11g Temporary Tablespace.txt
1.11G改進了Temporary Tablespace管理,可以回收臨時表空間.
alter tablespace temp shrink space;
alter tablespace temp shrink space keep 10m;
--也可以單獨回收一個臨時表空間資料檔案.
alter tablespace temp shrink tempfile '/u01/app/Oracle/oradata/test/temp01.dbf' keep 5m;
2.可以指定臨時表使用那個臨時表空間,這點對於一些應用比較有用.透過例子來說明:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
--//家裡僅僅12c,應該也能說明問題.
--//預設已經建立了臨時表空間.
CREATE TEMPORARY TABLESPACE TEMP TEMPFILE
'D:\APP\ORACLE\ORADATA\TEST\TEST01P\TEST01P_TEMP01.DBF' SIZE 388M AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
TABLESPACE GROUP ''
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
--//可以發現UNIFORM SIZE=1M,這樣加入每個session都要使用一些小的臨時表,每個至少需要1M,大量的會話佔用許多臨時表空間.
--//我們可以建立UNIFORM SIZE=64K的臨時表空間,而建立的臨時表指定到這個臨時表空間,這樣空間就沒有這麼浪費了.
CREATE TEMPORARY TABLESPACE TEMP01 TEMPFILE
'D:\APP\ORACLE\ORADATA\TEST\TEST01P\TEST01P_TEMP02.DBF' SIZE 100M AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 64K;
SCOTT@test01p> SCOTT@test01p> create global temporary table temp_test(id number ,text varchar2(100)) on commit delete rows tablespace temp01;
Table created.
SCOTT@test01p> insert into temp_test values (1,'a');
1 row created.
SCOTT@test01p> @ spid
SID SERIAL# SPID PID P_SERIAL# C50
---------- ---------- ------ ------- ---------- --------------------------------------------------
242 25 6808 22 5 alter system kill session '242,25' immediate;
--不提交執行如下:
SELECT s.username
,s.sid
,u.tablespace
,u.contents
,u.segtype
,ROUND (u.blocks * 8192 / 1024) KB
FROM v$session s, v$sort_usage u
WHERE s.saddr = u.session_addr AND u.contents = 'TEMPORARY'
ORDER BY KB DESC;
USERNAME SID TABLESPACE CONTENTS SEGTYPE KB
-------------------- ---------- ------------------------------ --------- --------- ----------
SCOTT 242 TEMP01 TEMPORARY DATA 64
--//這樣僅僅需要64K.
SCOTT@test01p> commit ;
Commit complete.
--如果不指定:
SCOTT@test01p> create global temporary table temp_testx(id number ,text varchar2(100)) on commit delete rows;
Table created.
SCOTT@test01p> insert into temp_testx values (1,'a');
1 row created.
USERNAME SID TABLESPACE CONTENTS SEGTYPE KB
-------------------- ---------- ------------------------------ --------- --------- ----------
SCOTT 242 TEMP TEMPORARY DATA 1024
--這樣即使插入很少的資料也使用1M.
3.看看這兩種不同UNIFORM SIZE的是否可以建立臨時表空間組:
SCOTT@test01p> ALTER TABLESPACE TEMP TABLESPACE GROUP ttt;
Tablespace altered.
SCOTT@test01p> ALTER TABLESPACE TEMP01 TABLESPACE GROUP ttt;
Tablespace altered.
--取消.
SCOTT@test01p> ALTER TABLESPACE TEMP TABLESPACE GROUP '';
Tablespace altered.
SCOTT@test01p> ALTER TABLESPACE TEMP01 TABLESPACE GROUP '';
Tablespace altered.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2123832/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Expert Tips on Drop Temporary Tablespace Hangs!!
- oracle的臨時表空間temporary tablespaceOracle
- 【案例分析】ORA-25153: Temporary Tablespace is Empty
- Oracle佇列鎖enq:TS,Temporary Segment (also TableSpace)Oracle佇列ENQ
- 臨時表空間temporary tablespace相關操作
- ORA-25153: Temporary Tablespace is Empty 解決方法
- Oracle10g New Feature -- 5.Temporary Tablespace GroupOracle
- Oracle 11g tablespace usageOracle
- Oracle10新特性:臨時表空間組(temporary tablespace group)Oracle
- 10G新特性: 臨時表空間組(temporary tablespace group)
- Oracle10g新特性:臨時表空間組(temporary tablespace group)Oracle
- ORA-25153: Temporary Tablespace is Empty 重建控制檔案導致丟失tempfile
- 重建控制檔案後,對臨時表空間(temporary tablespace)進行重建
- 11G的rsource角色與Unlimited TablespaceMIT
- oracle 11g expdb autoextend tablespace and create directory error;OracleError
- Allocation of Temporary Segments for Temporary Tables and Indexes (28)Index
- oracle temporary tableOracle
- tablespace 大檔案,undo,temp tablespace
- [Oracle Script] Temporary Sort UsageOracle
- Restrictions on Altering Temporary TablesREST
- Operations that Require Temporary Segments (26)UI
- db2 sms tablespace 不支援large tablespaceDB2
- Temporary tablespaces in RAC ? Oracle databas...Oracle
- 資料庫表--temporary table資料庫
- [virtualbox] temporary failure in name resolutionAI
- Tablespace Space Script
- remap_tablespaceREM
- The SYSAUX Tablespace (40)UX
- Oracle臨時表GLOBAL TEMPORARY TABLEOracle
- Oracle Temporary Tables(Oracle 臨時表)Oracle
- oracle的兩種global temporary table!Oracle
- [Oracle] 檢視tablespace的使用率(Including temp tablespace)Oracle
- Master Note for Tablespace IssuesAST
- TRANSPORT TABLESPACE總結
- Tablespace Repository (60)
- ftp_rawlist: Unable to create temporary file.FTP
- Sybase IQ 錯誤 : Temporary space limit exceededMIT
- 全域性臨時表 GLOBAL TEMPORARY TABLE