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

Oracle误删除表空间的恢复

[日期:2014-02-13] 来源:Linux社区  作者:Linux [字体:大 中 小]

3 备份数据库
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@dest bak]$ ls
crm201402091452.log  crm201402091727.log  fullbk.txt  rman.sh
[oracle@dest bak]$ cat rman.sh
#!/bin/bash
export today=`date +%Y%m%d%H%M`
export ORACLE_HOME=/oracle/app/db1
export ORACLE_SID=CRM
$ORACLE_HOME/bin/rman target sys/DHHZDHHZ log=/oracle/bak/crm.log cmdfile=/oracle/bak/fullbk.txt
mv /oracle/bak/crm.log  "/oracle/bak/crm${today}.log"


[oracle@dest bak]$ cat fullbk.txt
run{
delete noprompt obsolete;
crosscheck backup;
delete noprompt expired backup;
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup incremental level=0  database format '/backup/crm/full-%T-%U.bak';
backup archivelog all  format '/backup/crm/arch-%T-%U.bak';
backup current controlfile format '/backup/crm/ctl-%T-%U.bak';
backup spfile format '/backup/crm/spf-%T-%U.bak';
delete noprompt archivelog all completed before 'SYSDATE - 7';
}
[oracle@dest bak]$ ./rman.sh
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> [oracle@dest bak]$
[oracle@dest bak]$
[oracle@dest bak]$
[oracle@dest bak]$ rman target /


Recovery Manager: Release 11.2.0.2.0 - Production on Sun Feb 9 18:32:41 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to target database: CRM (DBID=3641885733)


RMAN> list backup of tablespace jxc;


using target database control file instead of recovery catalog


List of Backup Sets
===================

 


BS Key  Type LV Size      Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
23      Incr 0  2.04G      DISK        00:02:29    2014-02-09 18:31:05
        BP Key: 23  Status: AVAILABLE  Compressed: NO  Tag: TAG20140209T182835
        Piece Name: /backup/crm/full-20140209-0np076ik_1_1.bak
  List of Datafiles in backup set 23
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  5    0  Incr 3891775    2014-02-09 18:28:36 /oracle/CRM/jxc.dbf


RMAN> exit

 


4 在表空间上创建测试数据
[oracle@dest bak]$ sqlplus zx/dhhzdhhz


SQL*Plus: Release 11.2.0.2.0 Production on Sun Feb 9 18:33:07 2014


Copyright (c) 1982, 2010, Oracle.  All rights reserved.

 


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

 


SQL> create table test1(i int);                     


Table created.


SQL> begin
  2  for i in 1..20 loop
  3  insert into test1 values(i);
  4  end loop;
  5  commit;
  6  end;
  7  /


PL/SQL procedure successfully completed.


SQL> select * from zx.test1;


        I
----------
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11


        I
----------
        12
        13
        14
        15
        16
        17
        18
        19
        20


20 rows selected.
SQL> exit 
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@dest bak]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.2.0 Production on Sun Feb 9 18:34:17 2014


Copyright (c) 1982, 2010, Oracle.  All rights reserved.

 


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> alter system checkpoint;


System altered.


SQL> alter system switch logfile;


System altered.


5 记录drop掉表空间前当前数据库的时间点。


SQL> select current_scn,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from v$database;


CURRENT_SCN TO_CHAR(SYSDATE,'YY
----------- -------------------
    3892004 2014-02-09 18:35:05


SQL>
SQL>
SQL> alter system checkpoint;


System altered.


SQL> alter system switch logfile;


System altered.


6 drop掉表空间和相应的数据文件


SQL> drop tablespace jxc including contents and datafiles;


Tablespace dropped.

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

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