马儿涂鸦
数据库默认临时表空间
08月28日(星期日)

 
   在9i之前,如果一个数据库用户没有被指定默认临时表空间,那么oracle就会使用system表空间作为该用户的临时表空间,这是很危险的。在9i里 面,database可以被指定一个默认临时表空间。这样如果数据库用户没有被明确指定临时表空间,oracle 9i就会自动指定database的默认临时表空间作为该用户的临时表空间。
  
   我们可以通过下面的语句来查询数据库的默认临时表空间:
  
  SQL> select * from database_properties where property_name = 'DEFAULT_TEMP_TABLESPACE';
  
  PROPERTY_NAME PROPERTY_VALUE DESCRIPTION
  
  --------------------- ------------------- ------------------------
  
  DEFAULT_TEMP_TABLESPACE TEMP Name of default temporary tablespace
  
   默认临时表空间的限制:
  
  1. 默认临时表空间必须是TEMPORARY的:
  
   SQL> alter database default temporary tablespace tools;
  
   alter database default temporary tablespace tools
  
   *
  
   ERROR at line 1:
  
   ORA-12902: default temporary tablespace must be SYSTEM or of TEMPORARY type
  
   2. 默认临时表空间一旦被指定,将无法在改成PERMANET:
  
   SQL> alter tablespace temp2 permanent;
  
   alter tablespace temp2 permanent
  
   *
  
   ERROR at line 1:
  
   ORA-12904: default temporary tablespace cannot be altered to PERMANENT type
  
  3. 在删除默认临时表空间必须先重新指定默认临时表空间:
  
   SQL> drop tablespace temp including contents and datafiles;
  
   drop tablespace temp including contents and datafiles
  
   *
  
   ERROR at line 1:
  
   ORA-12906: cannot drop default temporary tablespace
  
   SQL> create tablespace TEMP2
  
   2 datafile '/data1/ora9data/temp2_01.dbf'
  
   3 size 100k TEMPORARY;
  
   Tablespace created.
  
   SQL> alter database default temporary tablespace TEMP2;
  
   Database altered.
  
   SQL> drop tablespace temp including contents and datafiles;
  
   Tablespace dropped.
  
   4. 默认临时表空间无法OFFLINE:
  
   SQL> alter tablespace temp offline;
  
   alter tablespace temp offline
  
   *
  
   ERROR at line 1:
  
   ORA-12905: default temporary tablespace cannot be brought OFFLINE
  
   5. 用户的临时表空间必须是TEMPORARY的(在9i之前没有这个限制,可以是PERMANENT):
  
   SQL> alter user scott temporary tablespace TOOLS;
  
   alter user scott temporary tablespace TOOLS
  
   *
  
   ERROR at line 1:
  
   ORA-12911: permanent tablespace cannot be temporary tablespace
  
   SQL> create tablespace temp2
  
   2 datafile '/data1/ora9data/temp2_01.dbf'
  
   3 size 100k temporary;
  
   Tablespace created.
  
   SQL> alter user scott temporary tablespace temp2;
  
   User altered.
  
   6. 如果删除了用户的临时表空间,而这个临时表空间又不是数据库的默认临时表空间(如果是数据库的默认临时表空间是删不掉的),用户的临时表空间不会自动转换到数据库的默认临时表空间上:
  
   SQL> select tablespace_name, contents from dba_tablespaces where tablespace_name like 'TEMP%';
  
   TABLESPACE_NAME CONTENTS
  
   ------------------------------ ---------
  
   TEMP TEMPORARY
  
   TEMP2 TEMPORARY
  
   SQL> select TEMPORARY_TABLESPACE from dba_users where username='SCOTT';
  
   TEMPORARY_TABLESPACE
  
   ------------------------------
  
   TEMP2
  
   SQL> drop tablespace TEMP2 including contents and datafiles;
  
   Tablespace dropped.
  
   SQL> select TEMPORARY_TABLESPACE from dba_users where username='SCOTT';
  
   TEMPORARY_TABLESPACE
  
   ------------------------------
  
   TEMP2

文章分类: 开发技术
前篇(05-08-27): Windows下常见Oracle服务介绍
后篇(05-08-29): 人生......少走弯路的十条建议!!!!!

发表评论
标题:
称呼:
内容:

引用链接
您可以按照以下步骤引用本文.本站收到您的引用通知后, 将自动链接您的文章, 以方便别人阅览 .
1. 启动您自己的博客管理页面, 并进入发表新文章的画面, 输入文章的内容. (如果您是ITPUB的博客请点这里.)
2. 复制下面虚线框里的连接字串, 把它们粘贴到您的文章中, 按照您的喜好修改一下表示文字.
3. 确认您选择了"发送引用通知"的选项.
4. 发表您的文章.
好啦, 您的文章就可以被自动链接到本站啦.

« 三月 2010 »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

Blog天地
  • eygle's blog
  • biti_rainy's blog
  • Fenng's Blog
  • Piner Blog
  • Louise's Blog
  • 沧海笑一声
  • dbanotes
  • DBA notes
  • bonny-erp
  • oracle‘blog


  • Creative Commons License 本站全部著作均采用CC授权. Plog 1.0 is powered by: plogworld.net.
    Itpub BLOG is provided by: itpub.net.
    This temlate(named Happy-Life's SunShine) is designed by lodge@itpub(肥猫猫).