Home Database Mysql Tutorial Oracle 10g 恢复操作概述

Oracle 10g 恢复操作概述

Jun 07, 2016 pm 05:20 PM
number

1. 实例恢复在实例重新启动时,系统自动恢复。判断依据:数据文件的scn与控制文件不一致。步骤:(1)使用online redo log,数据前

1. 实例恢复
     在实例重新启动时,系统自动恢复。
     判断依据:数据文件的scn与控制文件不一致。
     步骤:
     (1)使用online redo log,数据前滚到与控制文件一致的SCN处。
     (2)使用undo表空间,对未提交事务执行回滚操作。
     结果:数据库中数据保留到实例异常前最后一次提交的内容。
    
2. 用户错误恢复

   用户错误包括:用户数据错误修改,数据表误删等
   恢复技术:闪回查询(Flashback Query)
             Flashback Drop和表空间回收站(Tablespace's recycle bin)
             闪回表(Flashback Table)
             LogMiner

 

2.1 闪回查询
  
    前提:undo表空间足够容纳用户在一段时期内修改的数据
          undo表空间保留历史修改数据的时限(UNDO_RETETION初始变量)
         
    查询表employees在15分钟前的数据:

    SELECT employee_id, last_name, email FROM hr.employees
      AS OF TIMESTAMP(systimestamp - interval '15' minute)
      WHERE employee_id = 101;

 

    查询表employees在指定历史时间的数据:

    SELECT employee_id, last_name, email FROM hr.employees
      AS OF TIMESTAMP(
        to_timestamp('01-Sep-04 16:18:57.84', 'DD-Mon-RR HH24:MI:SS.FF'))
      WHERE employee_id = 101;

 

2.2 Flashback Drop和表空间回收站

 

    每个Oracle表空间中存在一个Recycle bin,用户存放删除的表和表相关内容(索引等)
    删除的表所占用的空间并不立即回收,但在视图DBA_FREE_SPACE中可看到。

 

    # 恢复已删除的数据表到删除前状态(包括表中数据):

    SQL> FLASHBACK TABLE order_items TO BEFORE DROP;

 

    # 恢复已删除的数据表并改名:   
    SQL> FLASHBACK TABLE order_items TO BEFORE DROP RENAME TO order_items_old;

 

    如果同一个表被删除恢复多次,如果需要恢复到以前的版本,则可以查询视图RECYCLEBIN
    或者使用命令SHOW RECYCLEBIN,并使用其中的表名称。

    使用限制:
        仅能用于非系统本地管理的表空间。
        位图联合索引、参照完整性约束、物化视图删除后无法保存在Recyclebin.
        使用Drop Index删除索引,删除的索引不会保存(只有删除表,,县官索引才保存)。


2.3 Flashback表

    允许将一个或多个表恢复到历史指定时间的状态。无需使用太耗时的操作。
    Flashback Table使用对相关事务的Undo操作恢复表,使用undo表空间。
    (Flashback Drop直接回收恢复表占用的空间)
    需要启用行迁移(row movement)功能。undo操作可能会改变记录的rowid.

 

    #启用Row Movement
    SQL> ALTER TABLE hr.employees ENABLE ROW MOVEMENT;

 

    #使用Flashback Table恢复表到指定时间
    SQL> FLASHBACK TABLE hr.employees [, ...]
         TO TIMESTAMP systimestamp - interval '15' minute;

 

2.4 LogMiner
  
    从Redo Log中提取所有的DDL和DML活动的语句。
    使用V$LOGMNR_CONTENTS视图查看(首先需要执行DBMS_LOGMNR.START_LOGMNR()过程)
    LogMiner工具本身不能用于恢复数据库
    仅从RedoLog中提取用于恢复数据库的SQL语句。

 

3. 控制文件恢复

    如果有控制文件发生错误,Oracle实例将停止运行。
    如果没有停止,则必须手动执行:SHUTDOWN ABORT
   
    将未损坏的控制文件复制一份到目标地址,并修改初始化参数中出问题的
    控制文件的路径到新的控制文件
    或者在初始化参数中把有问题的控制文件条目删除。
    控制文件错误时,修改初始化参数参数,需要在NOMOUNT状态下。

 

    SQL> SHUTDOWN IMMEDIATE;
    SQL> STARTUP NOMOUNT;
    SQL> SHOW PARAMETER CONTROL_FILES;
      或
    SQL> SELECT name, value FROM v$spparameters
         WHERE name = 'control_files';
    SQL> ALTER SYSTEM SET CONTROL_FILES='...','...','...' SCOPE=SPFILE;
    SQL> SHUTDOWN IMMEDIATE;
    SQL> STARTUP;
  

4. 重做日志恢复

   只要有一组中还有一个Redo Log文件还有可用,Oracle实例就不会崩溃。
   (即一个redo log组中所有redo log文件全部失效,Oracle示例就会崩溃)
   使用V$LOGFILE视图查询当前redo log文件的状态。
  
   如果一个redo log组中存在错误的redo log文件,那么按以下步骤恢复:
  
   # 确认哪个文件出现错误(在哪个组中)
   SQL> SELECT * FROM v$logfile ORDER BY group#;

 

   # 对该组redo log执行归档操作
   SQL> ALTER SYSTEM ARCHIVE LOG GROUP ;
  
   # 清空有问题的redo log组并重建
   SQL> ALTER DATABASE CLEAR LOGFILE GROUP ;
  
5. 系统关键数据文件恢复

    包括SYSTEM表空间和UNDO表空间。

 

5.1 NOARCHIVELOG 模式下

    只能依赖于是否对数据库有全备份,如果有,则只能恢复到全备份时。

 

5.2 ARCHIVELOG 模式下

 

    SQL> SHUTDOWN ABORT;    # 强制停止
    SQL> STARTUP MOUNT;     # 只能在Mount状态下恢复

 

    在EM的Perform Recovery中,选择恢复数据文件,以及对应的SYSTEM表空间数据文件。
    并可指定需要恢复到的目标路径。系统将会执行RMAN脚本进行恢复。

 

    SQL> ALTER DATABASE OPEN; # 恢复完毕后打开数据库

 

6. 非系统数据文件恢复

 

6.1 NOARCHIVELOG 模式下

    只能依赖于是否对数据库有全备份,如果有,则只能恢复到全备份时。

 

6.2 ARCHIVELOG 模式下

    只影响到丢失的数据文件相关的数据库对象。
    同样可在EM中,按步骤执行Perform Recovery进行恢复。

 

    # 查看数据文件
    SQL> SELECT t.name, d.name FROM v$tablespace t
         JOIN  v$datafile d USING (ts#)
         WHERE t.name = 'USERS';

 

    也可以执行RMAN命令恢复编号为4和7的数据文件:

 

    $ rman target /
    RMAN> run { sql 'alter database datafile 4 offline';
                sql 'alter database datafile 7 offline';
                restore datafile 4, 7;
                recover datafile 4, 7;
                sql 'alter database datafile 4 online';
                sql 'alter database datafile 7 online'; }

linux

Statement of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Top 10 Global Digital Virtual Currency Trading Platform Ranking (2025 Authoritative Ranking) Top 10 Global Digital Virtual Currency Trading Platform Ranking (2025 Authoritative Ranking) Mar 06, 2025 pm 04:36 PM

In 2025, global digital virtual currency trading platforms are fiercely competitive. This article authoritatively releases the top ten digital virtual currency trading platforms in the world in 2025 based on indicators such as transaction volume, security, and user experience. OKX ranks first with its strong technical strength and global operation strategy, and Binance follows closely with high liquidity and low fees. Platforms such as Gate.io, Coinbase, and Kraken are at the forefront with their respective advantages. The list covers trading platforms such as Huobi, KuCoin, Bitfinex, Crypto.com and Gemini, each with its own characteristics, but investment should be cautious. To choose a platform, you need to consider factors such as security, liquidity, fees, user experience, currency selection and regulatory compliance, and invest rationally

C program to find the largest prime factor of a number C program to find the largest prime factor of a number Aug 27, 2023 am 10:09 AM

PrimeFactor−Innumbertheory,theprimefactorsofapositiveintegeraretheprimenumbersthatdividethatintegerexactly.Theprocessoffindingthesenumbersiscalledintegerfactorization,orprimefactorization.Example−Primefactorsof288are:288=2x2x2x2x2

Top 10 exchanges in the currency circle in 2025 latest digital currency app rankings Top 10 exchanges in the currency circle in 2025 latest digital currency app rankings Feb 27, 2025 pm 06:33 PM

Ranking of the top ten virtual currency trading platforms (latest in 2025): Binance: Global leader, high liquidity, and regulation has attracted attention. OKX: Large user base, supports multiple currencies, and provides leveraged trading. Gate.io: A senior exchange, with a variety of fiat currency payment methods, providing a variety of trading pairs and investment products. Bitget: Derivatives Exchange, high liquidity, low fees. Huobi: An old exchange that supports a variety of currencies and trading pairs. Coinbase: A well-known American exchange, strictly regulated. Phemex and so on.

Top 10 digital currency trading platforms The latest list of top 10 digital currency trading platforms Top 10 digital currency trading platforms The latest list of top 10 digital currency trading platforms Mar 17, 2025 pm 05:57 PM

Top 10 digital currency trading platforms: 1. OKX, 2. Binance, 3. Gate.io, 4. Huobi Global, 5. Kraken, 6. Coinbase, 7. KuCoin, 8. Bitfinex, 9. Crypto.com, 10. Gemini, these exchanges have their own characteristics, and users can choose the platform that suits them based on factors such as security, fees, currency selection, user interface and customer support.

The world's top ten virtual currency trading platform app genuine download and installation tutorial The world's top ten virtual currency trading platform app genuine download and installation tutorial Mar 12, 2025 pm 05:33 PM

This article provides Android and Apple mobile APP download methods for mainstream digital currency trading platforms such as Binance, OKX, Gate.io, Huobi Global, Coinbase, KuCoin, Kraken and Bitfinex. Whether it is an Android user or an Apple user, you can easily find the official APP download link for the corresponding platform and complete the installation according to the steps. The article provides detailed guidance on searching and downloading on their respective official websites or app stores, and provides instructions on the special steps for installing APK files on Android, so that users can download and use them quickly and easily.

Top 10 trading platforms for digital currency apps, regular currency speculation platform app recommendations Top 10 trading platforms for digital currency apps, regular currency speculation platform app recommendations Mar 07, 2025 pm 06:51 PM

This article recommends ten digital currency trading apps: 1. OKX; 2. Binance; 3. Gate.io; 4. Huobi Global; 5. Kraken; 6. Coinbase; 7. KuCoin; 8. Crypto.com; 9. Bitfinex; 10. Poloniex. When choosing a platform, you need to consider factors such as security, liquidity, transaction fees, currency selection, user interface, customer service support and regulatory compliance, and carefully evaluate risks and never blindly follow the trend.

What are the reliable digital currency platforms? Top 10 formal digital currency trading platforms 2025 What are the reliable digital currency platforms? Top 10 formal digital currency trading platforms 2025 Mar 17, 2025 pm 05:45 PM

Reliable digital currency platforms include: 1. OKX, 2. Binance, 3. Gate.io, 4. Huobi Global, 5. Kraken, 6. Coinbase, 7. KuCoin, 8. Bitfinex, 9. Crypto.com, 10. Gemini. These exchanges have their own characteristics. Users can choose the platform that suits them based on factors such as security, fees, currency selection, user interface and customer support.

Top 10 digital currency app trading platforms top10 virtual currency app 2025 rankings Top 10 digital currency app trading platforms top10 virtual currency app 2025 rankings Mar 13, 2025 pm 07:00 PM

The rankings of the top ten virtual currency trading platforms are: 1. OKX; 2. Binance; 3. Gate.io; 4. Huobi Global; 5. Kraken; 6. Coinbase; 7. KuCoin; 8. Crypto.com; 9. Bitfinex; 10. Gemini. The ranking is based on comprehensive considerations such as platform liquidity, currency selection, security, user experience, handling fees and compliance, but is for reference only. Investment should be cautious and at your own risk.

See all articles