標籤:
Oracle 10g之前,同一使用者的多個會話只可以使用同一個暫存資料表空間,因為在給定的時間只有一個暫存資料表空間預設給使用者,為瞭解決這個潛在的瓶頸,Oracle支援暫存資料表空間組即包含多個暫存資料表空間的集合。暫存資料表空間組邏輯上就相當於一個暫存資料表空間。
Example:
1 SQL>create temporary tablespace temp1 tempfile ‘/u01/app/oracle/oradata/orcl/temp01.dbf‘ size 10M; 2 3 SQL>create temporary tablespace temp2 tempfile ‘/u01/app/oracle/oradata/orcl/temp02.dbf‘ size 10M; 4 5 SQL>create temporary tablespace temp3 tempfile ‘/u01/app/oracle/oradata/orcl/temp03.dbf‘ size 10M; 6 7 SQL>select name from v$tempfile; 8 9 NAME10 11 -----------------------------------------------------------------------------------------------12 13 /u01/app/oracle/oradata/orcl/temp01.dbf14 15 /u01/app/oracle/oradata/orcl/temp02.dbf16 17 /u01/app/oracle/oradata/orcl/temp01.dbf18 19 SQL>select tablespace_name from dba_tablespaces where contents=‘TEMPORARY‘;20 21 TABLESPACE_NAME22 23 -----------------------------------------------------------------------------------------------24 25 TEMP126 27 TEMP228 29 TEMP330 31 添加temp1,temp2,temp3到暫存資料表空間組tempgrp中32 33 SQL>alter tablespace temp1 tablespace group tempgrp;34 35 SQL>alter tablespace temp2 tablespace group tempgrp;36 37 SQL>alter tablespace temp3 tablespace group tempgrp;38 39 啟用暫存資料表空間組40 41 SQL>alter database default temporary tablespace tempgrp;42 43 SQL>select * from dba_tablespace_groups;44 45 GROUP_NAME TABLESPACE_NAME46 47 -----------------------------------------------------------------------------------------48 49 TEMPGRP TEMP150 51 TEMPGRP TEMP252 53 TEMPGRP TEMP354 55 此時資料庫所有使用者的預設暫存資料表空間為tempgrp56 57 SQL>select username,defualt_tablespace,temporary_tablespace from dba_user where username=‘SCOTT‘;58 59 USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE60 61 ---------------------------------------------------------------------------------------------------------------62 63 SCOTT USERS TEMPGRP64 65 刪除暫存資料表空間組66 67 1.必須先刪除成員68 69 SQL>alter tablespace temp1 tablespace group ‘‘;(表示刪除temp1)70 71 SQL>select * from dba_tablespace_groups;72 73 GROUP_NAME TABLESPACE_NAME74 75 -----------------------------------------------------------------------------------------76 77 TEMPGRP TEMP278 79 TEMPGRP TEMP380 81 同理將temp2,temp3刪除82 83 當資料表空間組是資料庫預設資料表空間時,最後一個成員刪除報錯:ORA-10919:Defualt temporary tablespace group must be have at least one tablespace84 85 SQL>alter database default temporary tablespace temp;86 87 此時再刪除最後一個成員,暫存資料表空間組自動消失88 89 SQL>select * from dba_tablespace_groups;90 91 no rows selected92 93 刪除temp1資料表空間及資料檔案94 95 SQL>drop temporary tablespace temp1 including contents and datafiles;
View Code
Oracle暫存資料表空間組