search
HomeDatabaseMysql TutorialOracle之DataBase闪回

Flashback Database 功能非常类似与RMAN的不完全恢复, 它可以把整个数据库回退到过去的某个时点的状态, 这个功能依赖于Flashba

Flashback Database 功能非常类似与RMAN的不完全恢复, 它可以把整个数据库回退到过去的某个时点的状态, 这个功能依赖于Flashback log 日志。 比RMAN更快速和高效。 因此Flashback Database 可以看作是不完全恢复的替代技术。 但它也有某些限制:

1. Flashback Database 不能解决Media Failure, 这种错误RMAN恢复仍是唯一选择

2. 如果删除了数据文件或者利用Shrink技术缩小数据文件大小,这时不能用Flashback Database技术回退到改变之前的状态,这时候就必须先利用RMAN把删除之前或者缩小之前的文件备份restore 出来, 然后利用Flashback Database 执行剩下的Flashback Datbase。

3. 如果控制文件是从备份中恢复出来的,或者是重建的控制文件,也不能使用Flashback Database。

4. 使用Flashback Database锁能恢复到的最早的SCN, 取决与Flashback Log中记录的最早SCN。

具体操作步骤如下:

1、开启Flashback Database的准备条件

a)、参数开关

select flashback_on,force_logging from v$database;

FLASHBACK_ON FORCE_LOGGING

------------ -------------

NO          NO

打开方法如下:

shutdown immediate;

startup mount;

alter database archivelog;

alter database flashback on;

alter database open;

alter database force logging;

到此,闪回数据库的2个参数FLASHBACK_ON和FORCE_LOGGING均打开;

b)、闪回文件存放位置db_recovery_file

show parameter db_recovery_file;

设置闪回区文件存放路径和大小:

alter system set db_recovery_file_dest='/dba/fb' scope=both; --默认的路径位置一般不改变

alter system set db_recovery_file_dest_size=6G scope=both;

c)、设置可闪回时长

alter system set db_flashback_retention_target =1440 scope=both;

该参数用来控制flashback log 数据保留的时间,或者说,你希望flashback database 能够恢复的最早的时间点。

默认值是1440,单位是minute,即24 小时,需要注意的是该参数虽然未直接指定flash recovery area大小,但却受其制约,

举个例子假如数据库每天有10%左右的数据变动的话,如果该初始化参数值设置为1440,则flash recovery area 的大小至少要是当前数据库实际容量的10%,

如果该初始化参数设置为2880,则flash recovery area 的大小就至少是数据库所占容量的20%。

到此,数据库闪回条件已经准备完毕。

2、闪回最早时间的查看,若闪回的时刻比oldest_flashback_time还早,会报日志不足的错误.

select t.oldest_flashback_scn, t.oldest_flashback_time from  v$flashback_database_log t ;

3、闪回操作

shutdown immediate;

startup mount;

Flashback database to timestamp to_timestamp('2013-11-23 11:41:16','yy-mm-dd hh24:mi:ss'); --此时刻不能早于前面查出来的闪回最早时间

4、 打开数据库:

在执行完flashback database 命令之后,Oracle 提供了两种方式让你修复数据库:

1). 直接alter database open resetlogs 打开数据库,当然,指定scn 或者timestamp 时间点之后产生的数据统统丢失。--此种方法等于是把数据库改到历史时间点了,闪回时间点后的一切都会消失。

2). 先执行alter database open read only 命令以read-only 模式打开数据库,,然后立刻通过逻辑导出的方式将误操作涉及表的数据导出,

再执行recover database 命令以重新应用数据库产生的redo,将数据库修复到flashback database 操作前的状态,

操作如下:

alter database open read only;

PL/SQL工具,右击对象名,导出丢失的数据;

shutdown immediate;

startup mount;

recover database;--用redo日志进行数据库恢复,取消了闪回对数据库的影响;

alter database open;

说明:

 执行recover database时 ,Oracle会以当前controlfile所纪录的SCN为准,利用archive log和 redo log的redo entry, 把相关的datafile 的 block恢复到“当前controlfile所纪录的SCN”。

相关阅读:

Oracle 11g flashback Data Archive(闪回数据归档)

Oracle flashback闪回机制

flashback table快速恢复误删除的数据

Oracle 备份恢复:flashback闪回

[Oracle]闪回flashback功能的使用

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.