Flash back database operations in Oracle Database 10 GB

Source: Internet
Author: User

 

Flash back database operations in Oracle Database 10 GB

You can use flashback database to restore the database to a previous time point or an SCN number.
In versions earlier than Oracle10g, to restore the database to a previous time point or SCN number, only
It is achieved through incomplete database recovery. From Oracle 10 Gb, you can use flashback Database
.

The use of flashback database is much faster than the Incomplete recovery of the execution database system,
However, you need to configure the database as follows:
1. The database must run in archive mode.
2. You must enable the database flash function.
3. You must configure the initialization parameter db_flashback_retention_target.

Flash back operation syntax

Flashback [standby | database] [database name]
To SCN number | timestamp time expression | Restore Point recovery point

 

 

Configure the flash back database Option

SQL> shutdown immediate;
The database has been closed.
The database has been detached.
The Oracle routine has been disabled.
SQL> startup Mount;
The Oracle routine has been started.

Total system global area 289406976 bytes
Fixed size 1248600 bytes
Variable Size 92275368 bytes
Database buffers 192937984 bytes
Redo buffers 2945024 bytes
The database has been loaded.

SQL> select name, log_mode, open_mode, flashback_on from V $ database;

Name log_mode open_mode flashback_on
-------------------------------------------------
Myoracle archivelog mounted no

SQL> alter database flashback on;

The database has been changed.

SQL & gt; Alter system set db_flashback_retention_target = 3600;

The system has been changed.

SQL> alter database open;

The database has been changed.

SQL> drop table Scott. EMP;

The table has been deleted.

SQL> select to_char (oldest_flashback_time, 'yyyy-mm-DD: hh24: MI: ss ')
2 from V $ flashback_database_log;

To_char (oldest_flas
-------------------
2008-01-02: 13: 20: 59

SQL> shutdown immediate;
The database has been closed.
The database has been detached.
The Oracle routine has been disabled.
SQL> startup Mount;
The Oracle routine has been started.

Total system global area 289406976 bytes
Fixed size 1248600 bytes
Variable Size 92275368 bytes
Database buffers 192937984 bytes
Redo buffers 2945024 bytes
The database has been loaded.

SQL> flashback database to timestamp to_date ('2017-01-02: 13: 20: 59 ',
2 'yyyy-mm-DD: hh24: MI: ss ');

Flash back complete.

SQL> alter database open resetlogs;

The database has been changed.

SQL> select * from Scott. EMP;

Empno ename job Mgr hiredate Sal comm deptno
-----------------------------------------------------------------------------------
7369 Smith clerk 7902-12-80 800 20
7499 Allen salesman 7698 20-2 month-81 1600 300 30
7521 ward salesman 7698 22-2 month-81 1250 500 30
7566 Jones manager 7839 2975-81 20
7654 Martin salesman 7698 28-9 month-81 1250 1400 30
7698 Blake manager 7839 01-5 months-81 2850 30
7782 Clark manager 7839-81 2450 10
7788 Scott analyst 7566-87 3000 20
7839 King President 17-11 month-81 5000 10
7844 Turner salesman 7698 month-81 1500 0 30
7876 Adams clerk 7788 month-87 1100 20

Empno ename job Mgr hiredate Sal comm deptno
-----------------------------------------------------------------------------------
7900 James Clerk 7698 03-12 months-81 950 30
7902 Ford analyst 7566 03-12 months-81 3000 20
7934 Miller clerk 7782 23-1 month-82 1300 10

14 rows have been selected.

Returns to a system change number (SCN)

SQL> truncate table Scott. EMP;

The table is truncated.

SQL> select * from Scott. EMP;

Unselected row

SQL> truncate table Scott. EMP;

The table is truncated.

SQL> truncate table Scott. EMP;

The table is truncated.

SQL> select oldest_flashback_scn from V $ flashback_database_log;

Oldest_flashback_scn
--------------------
737192

SQL> select oldest_flashback_scn from V $ flashback_database_log;

Oldest_flashback_scn
--------------------
737192

SQL> shutdown immediate;
The database has been closed.
The database has been detached.
The Oracle routine has been disabled.

SQL> startup Mount;
The Oracle routine has been started.

Total system global area 289406976 bytes
Fixed size 1248600 bytes
Variable Size 96469672 bytes
Database buffers 188743680 bytes
Redo buffers 2945024 bytes
The database has been loaded.

SQL> flashback database to SCN 737192;

Flash back complete.

SQL> alter database open resetlogs;

The database has been changed.

SQL> select * from Scott. EMP;

Empno ename job Mgr hiredate Sal comm deptno
-----------------------------------------------------------------------------------
7369 Smith clerk 7902-12-80 800 20
7499 Allen salesman 7698 20-2 month-81 1600 300 30
7521 ward salesman 7698 22-2 month-81 1250 500 30
7566 Jones manager 7839 2975-81 20
7654 Martin salesman 7698 28-9 month-81 1250 1400 30
7698 Blake manager 7839 01-5 months-81 2850 30
7782 Clark manager 7839-81 2450 10
7788 Scott analyst 7566-87 3000 20
7839 King President 17-11 month-81 5000 10
7844 Turner salesman 7698 month-81 1500 0 30
7876 Adams clerk 7788 month-87 1100 20

Empno ename job Mgr hiredate Sal comm deptno
-----------------------------------------------------------------------------------
7900 James Clerk 7698 03-12 months-81 950 30
7902 Ford analyst 7566 03-12 months-81 3000 20
7934 Miller clerk 7782 23-1 month-82 1300 10

14 rows have been selected.

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.