作者:david_zhang@sh 【轉載時請以超鏈接形式標明文章】
鏈接:http://www.cnblogs.com/david-zhang-index/archive/2012/04/11/2442726.html
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 NAME 10 11 ----------------------------------------------------------------------------------------------- 12 13 /u01/app/oracle/oradata/orcl/temp01.dbf 14 15 /u01/app/oracle/oradata/orcl/temp02.dbf 16 17 /u01/app/oracle/oradata/orcl/temp01.dbf 18 19 SQL>select tablespace_name from dba_tablespaces where contents='TEMPORARY'; 20 21 TABLESPACE_NAME 22 23 ----------------------------------------------------------------------------------------------- 24 25 TEMP1 26 27 TEMP2 28 29 TEMP3 30 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_NAME 46 47 ----------------------------------------------------------------------------------------- 48 49 TEMPGRP TEMP1 50 51 TEMPGRP TEMP2 52 53 TEMPGRP TEMP3 54 55 此時數據庫所有用戶的默認臨時表空間為tempgrp 56 57 SQL>select username,defualt_tablespace,temporary_tablespace from dba_user where username='SCOTT'; 58 59 USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE 60 61 --------------------------------------------------------------------------------------------------------------- 62 63 SCOTT USERS TEMPGRP 64 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_NAME 74 75 ----------------------------------------------------------------------------------------- 76 77 TEMPGRP TEMP2 78 79 TEMPGRP TEMP3 80 81 同理將temp2,temp3刪除 82 83 當表空間組是數據庫默認表空間時,最后一個成員刪除報錯:ORA-10919:Defualt temporary tablespace group must be have at least one tablespace 84 85 SQL>alter database default temporary tablespace temp; 86 87 此時再刪除最后一個成員,臨時表空間組自動消失 88 89 SQL>select * from dba_tablespace_groups; 90 91 no rows selected 92 93 刪除temp1表空間及數據文件 94 95 SQL>drop temporary tablespace temp1 including contents and datafiles;
總結:oracle11g新特性
