如果自己搞不定可以找诗檀软件专业ORACLE数据库修复团队成员帮您恢复!
诗檀软件专业数据库修复团队
服务热线 : 13764045638 QQ号:47079569 邮箱:service@parnassusdata.com
适用于:
Oracle Server – Enterprise Edition – 版本 10.2.0.1到 11.2.0.2.0 [Release 10.2 到 11.2]
本文信息适用于任何平台。
目的
本文将详细介绍来使用闪回数据库技术恢复被错误drop的用户的步骤。
范围
本文针对各经验级别的DBA。
前提条件
– 数据库必须在归档日志模式
– 数据库数据库在闪回数据库模式。
– 用户被drop的时间必须在db_flashback_retention_target内且所有闪回个归档日志必须可用。
– 应该没有对于该用户schema中的任何对象的NOLOGGING 操作。
详细信息
这个测试情况包括以下步骤
步骤1 : 确保有足够的闪回日志来进行闪回数据库
步骤2 : 模拟人为错误 – User Drop
步骤3: 执行Flashback Database
步骤4: 在只读模式下打开闪回数据库
步骤5: 检查用户可用性和其数据
步骤6: 对被dropschema进行完整导出
步骤7: 执行数据库的FULL完整恢复使其到当前状态
步骤8: 导入用户来解决人为错误 – user drop
*** 恢复被drop用户而不丢失任何数据 ***
- 确保数据库在闪回模式
SQL> select flashback_on from v$database;
FLASHBACK_ON
——————
YES
SQL> show parameter flash
NAME VALUE
——————————- ———–
db_flashback_retention_target 1440
SQL> select oldest_flashback_scn,oldest_flashback_time from $flashback_database_log ;
OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TIM
——————————— ——————————–
24300236 29-MAY-2009 12:56:13
- 要模拟问题,在现有用户中创建几个表然后drop它。
SQL> conn flashback_test/flashback
Connected.
SQL> create table flashback_testing ( col1 varchar2(20));
Table created.
SQL> insert into flashback_testing values ( ‘flashback testing’);
1 row created.
SQL> commit;
Commit complete.
SQL> alter session set nls_date_format=’DD-MON-YYYY HH24:MI:SS’;
Session altered.
SQL> select sysdate from dual;
SYSDATE
——————–
29-MAY-2009 14:32:50
SQL> conn / as sysdba
Connected.
SQL> drop user falshback_test CASCADE;
User dropped.
- 要恢复丢失的schema,使用flashback database 功能到在user被drop的近似时间点。
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 289406976 bytes
Fixed Size 1290208 bytes
Variable Size 142606368 bytes
Database Buffers 142606336 bytes
Redo Buffers 2904064 bytes
Database mounted.
SQL> flashback database to timestamp to_date(’29-MAY-2009 14:30:00′,’DD-MON-YYYY HH24:MI:SS’);
Flashback complete.
4.在只读模式下打开数据库
SQL> alter database open read only;
Database altered.
- 查看用户和其相关数据
SQL> conn FALSHBACK_TEST/flashback
Connected.
SQL> select * from flashback_testing;
COL1
——————–
flashback testing
SQL> exit
- 对用户进行导出
C:\>exp owner=falshback_test file=E:\temp\exp1.dmp
Export: Release 10.2.0.4.0 – Production on Fri May 29 20:23:40 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Username: / as sysdba
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production
With the Partitioning, OLAP and Data Mining options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
About to export specified users …
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user FALSHBACK_TEST
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user FALSHBACK_TEST
About to export FALSHBACK_TEST’s objects …
. about to export FALSHBACK_TEST’s tables via Conventional Path …
. . exporting table FLASHBACK_TESTING 1 rows exported
. exporting synonyms
. exporting views
….
. exporting statistics
Export terminated successfully without warnings.
- 关闭数据库并恢复数据库使其到CURRENT状态
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 289406976 bytes
Fixed Size 1290208 bytes
Variable Size 142606368 bytes
Database Buffers 142606336 bytes
Redo Buffers 2904064 bytes
Database mounted.
SQL> recover database;
Media recovery complete.
SQL> alter database open;
Database altered.
现在该数据库在当前状态,而没有被drop的用户,但我们有在用户被drop前的完整export dump。
8.创建被drop用户并从export dump中将其再次导入
SQL> create user flashback_test identified by flashback default tablespace users quota unlimited on users;
User created.
SQL> — Grant the necessary priviledge to that user
C:\>imp full=y file=E:\temp\exp1.dmp
Import: Release 10.2.0.4.0 – Production on Fri May 29 20:26:14 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Username: / as sysdba
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via conventional path
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
. importing SYS’s objects into SYS
. importing FLASHBACK_TEST’s objects into FALSHBACK_TEST
. . importing table “FLASHBACK_TESTING” 1 rows imported
Import terminated successfully without warnings.
Now this database is upto date with the dropped table. NO DATA LOSS 🙂
限制:
1. 如果任何闪回日志或归档日志丢失,则以上选项不起作用。
2. 如果在恢复后有 NOLOGGING选项,这些NOLOGGING 事务块会软损坏。因此,使用FLASHBACK DATABASE时,避免使用与NOLOGGING操作一致的目标时间或SCN。
Comment