Oracle9i引入了全局缺省临时表空间,在创建用户时如果不指定用户临时表空间,缺省的Oracle会为用户指定这个全局缺省临时表空间。可是在很多情况下,我们可能需要重新创建临时表空间,并对数据库的临时表空间进行切换,这可以参考以下步骤。
首先我们可以通过dba_users视图查询到用户当前所使用的缺省临时表空间:
[oracle@jumper oracle]$ sqlplus "/ as sysdba" SQL*Plus: Release 9.2.0.4.0 - Production on Wed Apr 12 11:11:43 2006 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. SQL> select username,temporary_tablespace from dba_users; USERNAME TEMPORARY_TABLESPACE ------------------------------ ------------------------------ SYS TEMP2 SYSTEM TEMP2 OUTLN TEMP2 EYGLE TEMP2 CSMIG TEMP2 ...... 13 rows selected. SQL> select name from v$tempfile; NAME --------------------------------------------------------------------- /opt/oracle/oradata/conner/temp02.dbf /opt/oracle/oradata/conner/temp03.dbf
创建新的临时表空间:
SQL> create temporary tablespace temp tempfile '/opt/oracle/oradata/conner/temp1.dbf' size 10M; Tablespace created. SQL> alter tablespace temp add tempfile '/opt/oracle/oradata/conner/temp2.dbf' size 20M; Tablespace altered.
执行切换,将数据库的缺省临时表空间切换到新的表空间上:
SQL> alter database default temporary tablespace temp; Database altered.
此时检查所有用户的缺省临时表空间,已经全部顺利切换到新的表空间上:
SQL> select username,temporary_tablespace from dba_users; USERNAME TEMPORARY_TABLESPACE ------------------------------ ------------------------------ SYS TEMP SYSTEM TEMP OUTLN TEMP EYGLE TEMP CSMIG TEMP ....... 13 rows selected.
我们可以通过v$sort_usage视图查询,如果原临时表空间已经无用户使用,则可以安全删除该表空间:
SQL> drop tablespace temp2; Tablespace dropped. SQL> select name from v$tempfile; NAME --------------------------------------------------------------- /opt/oracle/oradata/conner/temp1.dbf /opt/oracle/oradata/conner/temp2.dbf SQL> select file_name,tablespace_name,bytes/1024/1024 MB,autoextensible 2 from dba_temp_files; FILE_NAME TABLESPACE_NAME MB AUTOEXTENSIBLE -------------------------------------- -------------------- ---------- -------------- /opt/oracle/oradata/conner/temp2.dbf TEMP 20 NO /opt/oracle/oradata/conner/temp1.dbf TEMP 10 NO
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。