增加自動擴充套件臨時表空間及改變預設表空間

mengzhaoliang發表於2008-09-17

增加自動擴充套件臨時表空間及改變預設表空間


1、檢視臨時表空間的大小
SQL> l
  1  select a.name "tablespace",b.name "name",b.bytes/1024/1024 "MB"
  2  from v$tablespace a,v$tempfile b
  3* where a.ts#=b.ts#
SQL> /

table name                                                       MB            
----- -------------------------------------------------- ----------            
TEMP  D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF           20            

                                     NUMBER

2、檢視臨時表空間大小、是否自動擴充套件

SQL> l
  1* select file_name,bytes/1024/1024 "MB",autoextensible,tablespace_name from dba_temp_files
SQL> /

FILE_NAME                                                  MB AUT              
-------------------------------------------------- ---------- ---              
TABLESPACE_NAME                                                                
------------------------------                                                 
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF           20 YES              
TEMP                                                                           
                                                                               


3、縮小臨時表空間檔案的大小,把20M縮小成5M
SQL> alter database tempfile
  2  'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF' resize 5M;

資料庫已更改。

 


SQL> select name,bytes/1024/1024 "MB" from v$tempfile;

NAME                                                       MB                  
-------------------------------------------------- ----------                  
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF            5                  

 

4、新建立一個自動擴充套件的臨時表空間
SQL> create temporary tablespace temp02
  2  tempfile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP02.DBF'
  3  size 4M autoextend on;

表空間已建立。

 

建立表空間時設定資料檔案的最大限制值:

SQL> create temporary tablespace temp02
  2  tempfile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP02.DBF'
  3  size 4M autoextend on maxsize 10M;

表空間已建立。

5、查詢目前資料庫中預設的臨時表空間

SQL> l
  1  select * from database_properties
  2* where property_name like 'DEFAULT%'
SQL> /

PROPERTY_NAM PROPERTY_VAL DESCRIPTION                                          
------------ ------------ --------------------                                 
DEFAULT_TEMP TEMP         Name of default temp                                 
_TABLESPACE               orary tablespace                                     
                                                                               
DEFAULT_PERM USERS        Name of default perm                                 
ANENT_TABLES              anent tablespace                                     
PACE                                                                           
                                                                               
DEFAULT_TBS_ SMALLFILE    Default tablespace t                                 
TYPE                      ype                                                  
                                                                               
                                      
6、查詢所有的臨時表空間
                                                                      
SQL> l
  1* select file_name,tablespace_name,bytes/1024/1024 "MB",autoextensible from dba_temp_files
SQL> /

FILE_NAME                      TABLESPA         MB AUT                         
------------------------------ -------- ---------- ---                         
D:\ORACLE\PRODUCT\10.2.0\ORADA TEMP              5 YES                         
TA\ORCL\TEMP01.DBF                                                             
                                                                               
D:\ORACLE\PRODUCT\10.2.0\ORADA TEMP02            4 YES                         
TA\ORCL\TEMP02.DBF                                                             
                                                                               
7、更改資料庫的預設表空間
SQL> alter database default temporary tablespace temp02;

資料庫已更改。

8、重新檢視資料庫的預設表空間
SQL> select * from database_properties
  2  where property_name like 'DEFAULT%';

PROPERTY_NAM PROPERTY_VAL DESCRIPTION                                          
------------ ------------ --------------------                                 
DEFAULT_TEMP TEMP02       Name of default temp                                 
_TABLESPACE               orary tablespace                                     
                                                                               
DEFAULT_PERM USERS        Name of default perm                                 
ANENT_TABLES              anent tablespace                                     
PACE                                                                           
                                                                               
DEFAULT_TBS_ SMALLFILE    Default tablespace t                                 
TYPE                      ype                                                  
                                                                               
9、檢視臨時表空間的資料檔案的狀態
SQL> select file#,status,bytes/1024/1024 "MB",name from v$tempfile;

     FILE# STATUS          MB NAME                                             
---------- ------- ---------- --------------------------------------------------
         1 ONLINE           5 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF 
         2 ONLINE           4 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP02.DBF 

 

10、刪除臨時表空間,不能是資料庫的預設臨時表空間

SQL> drop tablespace temp;

表空間已刪除。

SQL> select tablespace_name,status,contents from dba_tablespaces;

TABLESPA STATUS    CONTENTS                                                    
-------- --------- ---------                                                   
SYSTEM   ONLINE    PERMANENT                                                   
UNDOTBS1 ONLINE    UNDO                                                        
SYSAUX   ONLINE    PERMANENT                                                   
USERS    ONLINE    PERMANENT                                                   
EXAMPLE  ONLINE    PERMANENT                                                   
TEMP02   ONLINE    TEMPORARY                                                   

已選擇6行。


這樣就可以在作業系統上手工刪除臨時表空間的資料檔案。

 


 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12778571/viewspace-448762/,如需轉載,請註明出處,否則將追究法律責任。

相關文章