手机版
你好,游客 登录 注册
背景:
阅读新闻

Oracle临时表空间的管理与受损恢复

[日期:2013-06-21] 来源:CSDN  作者:robinson [字体:大 中 小]

4. 查看当前临时表使用空间大小与正在占用临时表空间的sql语句

-->使用临时段的SQL语句                                                       
 SELECT sess.SID, segtype, blocks * 8 / 1000 "MB", sql_text                 
 FROM  v$sort_usage sort, v$session sess, v$sql SQL                       
 WHERE  sort.SESSION_ADDR = sess.SADDR                                     
        AND SQL.ADDRESS = sess.SQL_ADDRESS                                 
 ORDER  BY blocks DESC;                                                     
                                                                             
-->下面的查询也可以查询谁正在使用临时段                                     
 col username format a15                                                   
 col machine format a15                                                     
 col program format a30                                                     
 col tablespace format a15                                                 
 set linesize 160                                                           
 SELECT s.username                                                         
      ,s.sid                                                               
      ,s.serial#                                                           
      ,s.sql_address                                                       
      ,s.machine                                                           
      ,s.program                                                           
      ,su.tablespace                                                       
      ,su.segtype                                                         
      ,su.contents                                                         
 FROM  v$session s, v$sort_usage su                                       
 WHERE  s.saddr = su.session_addr;                                         
                                                                             
SELECT 'the ' || NAME || ' temp tablespaces ' || tablespace_name ||         
      ' idle ' ||                                                           
      round(100 - (s.tot_used_blocks / s.total_blocks) * 100, 3) ||         
      '% at ' || to_char(SYSDATE, 'yyyymmddhh24miss')                       
FROM  (SELECT d.tablespace_name tablespace_name,                           
              nvl(SUM(used_blocks), 0) tot_used_blocks,                     
              SUM(blocks) total_blocks                                     
        FROM  v$sort_segment v, dba_temp_files d                           
        WHERE  d.tablespace_name = v.tablespace_name(+)                     
        GROUP  BY d.tablespace_name) s,                                     
      v$database; 

3. 修改默认的临时表空间

alter database default temporary tablespace tablespace_name;

4. 对于过度使用临时表空间,在允许的情况下,可以杀掉其session

alter system kill session 'sid,serial#';

三、临时表空间故障

前面已提到,临时表空间不需要备份,如果对临时表空间备份将收到错误提示

SQL> alter tablespace temp begin backup;                       
alter tablespace temp begin backup                             
*                                                             
ERROR at line 1:                                               
ORA-03217: invalid option for alter of TEMPORARY TABLESPACE   
                                                               
                                                               
SQL> alter temporary tablespace temp begin backup;             
alter temporary tablespace temp begin backup                   
      *                                                       
ERROR at line 1:                                               
ORA-00940: invalid ALTER command

临时表空间出错的错误提示(位于告警日志中alert_orcl.log)

Errors in file /u01/app/Oracle/admin/orcl/bdump/orcl_dbw0_2230.trc:

ORA-01186:file 3 failed verification tests

ORA-01157:cannot identify/lock data file 3 - see DBWR trace file

ORA-01110:data file 3:'/u01/app/oracle/oradata/orcl/temp01.dbf'

linux
相关资讯       Oracle临时表  Oracle临时表空间 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款