基于时间的恢复
SQL> select * from scott.emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
----- ---------- --------- ----- ----------- --------- --------- ------
7369 SMITH CLERK 7902 1980-12-17 800.00 20
7499 ALLEN SALESMAN 7698 1981-2-20 1600.00 300.00 30
7521 WARD SALESMAN 7698 1981-2-22 1250.00 500.00 30
7566 JONES MANAGER 7839 1981-4-2 2975.00 20
7654 MARTIN SALESMAN 7698 1981-9-28 1250.00 1400.00 30
7698 BLAKE MANAGER 7839 1981-5-1 2850.00 30
7782 CLARK MANAGER 7839 1981-6-9 2450.00 10
7839 KING PRESIDENT 1981-11-17 5000.00 10
7844 TURNER SALESMAN 7698 1981-9-8 1500.00 0.00 30
7900 JAMES CLERK 7698 1981-12-3 950.00 30
7902 FORD ANALYST 7566 1981-12-3 3000.00 20
7934 MILLER CLERK 7782 1982-1-23 1300.00 10
The current time is 12:00 p.m. on March 9, 2002.
The EMPLOYEES table has been dropped.
The table was dropped at approximately 11:45 a.m.
Database activity is minimal because most staff are currently in a meeting.
The table must be recovered.
为了模拟这个场景,我们将数据库恢复到删除emp表之前的样子
1)
SQL> select * from scott.com1;
N1
----------
1
取现在的系统时间
SQL> select to_char(sysdate,'yyyy-mm-dd:hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YY
-------------------
2007-12-02:15:33:22
2)
删除emp表
SQL> drop table scott.emp
SQL> insert into scott.com1 values(2);
SQL> commit;
SQL> alter system switch logfile;
在2007-12-02:15:33:22之后,又在scott.com1 中插入 数字 2
SQL> select * from scott.com1;
N1
----------
1
2
恢复
SQL> shutdown immediate
OS 中将所有的数据文件拿回来(除了control file 和redo log file)
SQL> startup mount
SQL> recover database until time '2007-12-02:15:33:22'
完成介质恢复。
SQL> alter database open resetlogs;
数据库已更改。
数据库恢复到2007-12-02:15:33:22的样子,为了使数据文件和redo log以及control file同步,必须重新reset
日志。
SQL> select * from scott.emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
----- ---------- --------- ----- ----------- --------- --------- ------
7369 SMITH CLERK 7902 1980-12-17 800.00 20
7499 ALLEN SALESMAN 7698 1981-2-20 1600.00 300.00 30
7521 WARD SALESMAN 7698 1981-2-22 1250.00 500.00 30
7566 JONES MANAGER 7839 1981-4-2 2975.00 20
7654 MARTIN SALESMAN 7698 1981-9-28 1250.00 1400.00 30
7698 BLAKE MANAGER 7839 1981-5-1 2850.00 30
7782 CLARK MANAGER 7839 1981-6-9 2450.00 10
7839 KING PRESIDENT 1981-11-17 5000.00 10
7844 TURNER SALESMAN 7698 1981-9-8 1500.00 0.00 30
7900 JAMES CLERK 7698 1981-12-3 950.00 30
7902 FORD ANALYST 7566 1981-12-3 3000.00 20
7934 MILLER CLERK 7782 1982-1-23 1300.00 10
emp表恢复了
SQL> select * from scott.com1;
N1
----------
1
在2007-12-02:15:33:22之后,又在scott.com1 中插入的数字2被丢失
阅读(2753) | 评论(0) | 转发(0) |