为TEMP表空间创建替换临时文件并物理删除后最简单的恢复方法

数据库物理结构分为数据文件和临时文件,临时文件和数据文件基本相同,只不过是 数据文件在逻辑结构上对应着表空间,而临时文件对应着临时表空间而已。它对数据库的影响很小,丢失临时文件的后果是需要利用临时表空间的排序SQL将会失败。
下面我们将为数据库的临时空间进行替换和、删除和恢复测试

1、替换临时表空间

点击(此处)折叠或打开

  1. [oracle@Primary oradata]$ sqlplus / as sysdba
  2. SQL*Plus: Release 11.2.0.4.0 Production on Mon Jul 25 09:03:13 2016
  3. Copyright (c) 1982, 2013, Oracle. All rights reserved.
  4. Connected to:
  5. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  6. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  7. SQL> col name for a40
  8. SQL>  select file#,name from v$tempfile;
  9. FILE#       NAME
  10. ---------- ----------------------------------------
  11. 1           /oracle/database/oradata/jingfan/temp01.dbf

  12. #增加一个临时文件
  13. SQL> alter tablespace temp add tempfile '/oracle/database/oradata/jingfan/temp02.ora' size 25m;
  14. Tablespace altered.

  15. SQL> select file#,name from v$tempfile;
  16.      FILE# NAME
    ---------- ----------------------------------------
             1 /oracle/database/oradata/jingfan/temp01.dbf
             2 /oracle/database/oradata/jingfan/temp02.ora
             
  17. #s删除一个临时文件
  18. SQL> alter tablespace temp drop tempfile '/oracle/database/oradata/jingfan/temp01.dbf';
  19. Tablespace altered.
  20. SQL> select file#,name from v$tempfile;
  21. FILE#      NAME
  22. ---------- ----------------------------------------
  23. 2          /oracle/database/oradata/jingfan/temp02.ora

  24. SQL> alter tablespace temp drop tempfile '/oracle/database/oradata/jingfan/temp02.ora';
  25. alter tablespace temp drop tempfile '/oracle/database/oradata/jingfan/temp02.ora'
  26. *
  27. ERROR at line 1:
  28. ORA-03261: the tablespace TEMP has only one file
  29. SQL> shutdown
  30. ^CORA-01013: user requested cancel of current operation
  31. SQL> shutdown immediate
  32. Database closed.
  33. Database dismounted.
  34. ORACLE instance shut down.
  35. SQL> !rm /oracle/database/oradata/jingfan/temp02.ora
  36. SQL> host ls -lt /oracle/database/oradata/jingfan/
  37. total 1894160
    -rw-r----- 1 oracle oinstall  10174464 Jul 25 09:07 control01.ctl
    -rw-r----- 1 oracle oinstall 262152192 Jul 25 09:06 rman.dbf
    -rw-r----- 1 oracle oinstall   5251072 Jul 25 09:06 users01.dbf
    -rw-r----- 1 oracle oinstall 608182272 Jul 25 09:06 sysaux01.dbf
    -rw-r----- 1 oracle oinstall  99622912 Jul 25 09:06 undotbs01.dbf
    -rw-r----- 1 oracle oinstall 796925952 Jul 25 09:06 system01.dbf
    -rw-r----- 1 oracle oinstall  52429312 Jul 25 09:06 redo01.log
    -rw-r----- 1 oracle oinstall  52429312 Jul 25 07:49 redo03.log
    -rw-r----- 1 oracle oinstall  52429312 Jul 25 07:49 redo02.log
  38. SQL>
二、恢复临时文件的最简单方式就是重启数据库,在启动时,如果在原来的磁盘目录可用,oracle就会在该目录下创建所有丢失的临时文件
点击( 此处 )折叠或打开
  1. #我们启动数据库是没有错误提示
  2. SQL> startup
  3. ORACLE instance started.
  4. Total System Global Area 776646656 bytes
  5. Fixed Size 2257272 bytes
  6. Variable Size 478154376 bytes
  7. Database Buffers 289406976 bytes
  8. Redo Buffers 6828032 bytes
  9. Database mounted.
  10. Database opened.
  11. #然后,我们跟踪一下alert日志信息,发下有一段Re-creating命令,正是重新穿件临时文件的操作
  12. ARC0: STARTING ARCH PROCESSES COMPLETE
    ARC0: Becoming the 'no FAL' ARCH
    ARC0: Becoming the 'no SRL' ARCH
    ARC2: Becoming the heartbeat ARCH
    [95862] Successfully onlined Undo Tablespace 2.
    Undo initialization finished serial:0 start:575491024 end:575491034 diff:10 (0 seconds)
    Verifying file header compatibility for 11g tablespace encryption..
    Verifying 11g file header compatibility for tablespace encryption completed
    SMON: enabling tx recovery
    Re-creating tempfile /oracle/database/oradata/jingfan/temp02.ora
    Database Characterset is AL32UTF8
    No Resource Manager plan active
    replication_dependency_tracking turned off (no async multimaster replication found)
    Starting background process QMNC
    Mon Jul 25 09:07:43 2016
    QMNC started with pid=25, OS id=95878 
    Completed: ALTER DATABASE OPEN


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27039319/viewspace-2122664/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27039319/viewspace-2122664/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值