Oracle10g新特性临时表空间组的示例分析

发布时间:2021-11-03 16:06:42 作者:柒染
来源:亿速云 阅读:165

Oracle10g新特性临时表空间组的示例分析,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

在oracle10g以前,每个用户只能使用一个临时表空间,就是其默认临时表空间。oracle10g提供了新的临时表空间组的功能,允许将多个临时表空间打包成一个组,然后指定用户的默认临时表空间为该临时表空间组,从而达到一个用户可以使用多个临时表空间的目的。

一个临时表空间组至少包含一个临时表空间。

临时表空间组无法显式创建,当第一个临时表空间分配给该组时自动创建,当组内所有临时表空间被移除时自动删除。

临时表空间组支持的操作:

使用临时表空间组的好处:

下面给出几个例子:

环境

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

1.创建临时表空间组
SQL> create temporary tablespace temp1
2 tempfile 'e:/oracle/oradata/ning/temp101.dbf' size 10m
3 tablespace group group1;

表空间已创建。

SQL> create temporary tablespace temp2
2 tempfile ''e:/oracle/oradata/ning/temp201.dbf' size 10m
3 tablespace group group1;

表空间已创建。

2.查看系统中目前存在的临时表空间组的信息
SQL> select * from dba_tablespace_groups;

GROUP_NAME TABLESPACE_NAME
------------------------------ ------------------------------
GROUP1 TEMP1
GROUP1 TEMP2

3.移动临时表空间到新的临时表空间组
SQL> alter tablespace temp2 tablespace group group2;

表空间已更改。

SQL> select * from dba_tablespace_groups;

GROUP_NAME TABLESPACE_NAME
------------------------------ ------------------------------
GROUP1 TEMP1
GROUP2 TEMP2

4.将临时表空间从临时表空间组中移出
SQL> alter tablespace temp2 tablespace group '';

表空间已更改。

SQL> select * from dba_tablespace_groups;

GROUP_NAME TABLESPACE_NAME
------------------------------ ------------------------------
GROUP1 TEMP1

5.临时表空间组的名字不能和表空间的名字冲突
SQL> create temporary tablespace temp3
2 tempfile ''e:/oracle/oradata/ning/temp301.dbf' size 10m
3 tablespace group temp3;
create temporary tablespace temp3
*
第 1 行出现错误:
ORA-10918: TABLESPACE GROUP name cannot be the same as tablespace name

SQL> create temporary tablespace temp3
2 tempfile 'e:/oracle/oradata/ning/temp301.dbf' size 10m
3 tablespace group temp1;
create temporary tablespace temp3
*
第 1 行出现错误:
ORA-01543: 表空间 'TEMP1' 已存在

6.删除组中所有的临时表空间后,组会自动删除
SQL> select * from dba_tablespace_groups;

GROUP_NAME TABLESPACE_NAME
------------------------------ ------------------------------
GROUP1 TEMP1

SQL> drop tablespace temp1 including contents and datafiles;

表空间已删除。

SQL> select * from dba_tablespace_groups;

未选定行

7.可以将数据库或者用户的默认临时表空间指定为临时表空间组
SQL> create temporary tablespace temp1
2 tempfile ''e:/oracle/oradata/ning/temp101.dbf' size 10m
3 tablespace group group1;

表空间已创建。

SQL> alter tablespace temp2 tablespace group group1;

表空间已更改。

SQL> select * from dba_tablespace_groups;

GROUP_NAME TABLESPACE_NAME
------------------------------ ------------------------------
GROUP1 TEMP1
GROUP1 TEMP2

SQL> alter database default temporary tablespace group1;

数据库已更改。

SQL> alter user ning temporary tablespace group1;

用户已更改。

8.同一个用户的不同session可以使用不同的临时表空间

首先用sys用户查询
SQL> select username, session_num, tablespace from v$sort_usage;

未选定行

新开session1执行
SQL> conn ning/ning
已连接。

select a.table_name, b.table_name from dict A, dict B order by a.table_name;

新开session2执行
SQL> conn ning/ning
已连接。

select a.table_name, b.table_name from dict A, dict B;

sys查询:
SQL> select username, session_num, tablespace from v$sort_usage;

USERNAME SESSION_NUM TABLESPACE

NING 74 TEMP2
NING 62 TEMP1

可以发现,同一个用户ning的两个session分别使用了两个不同的临时表空间。

关于Oracle10g新特性临时表空间组的示例分析问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

推荐阅读:
  1. linux中用户组以及权限的示例分析
  2. Bootstrap列表组的示例分析

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

oracle10g 新特性 特性

上一篇:pip在Linux、Mac和Windows系统上的安装过程是什么

下一篇:怎么掌握Python列表

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》