作者:david_zhang@sh 【转载时请以超链接形式标明文章】
链接:
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;
总结:oracle11g新特性