Oracle Flashback and RMAN examples, flashbackrman

Source: Internet
Author: User

Oracle Flashback and RMAN examples, flashbackrman
Author: Grey original address: http://www.cnblogs.com/greyzeng/p/5346833.html

 

Environment:
  • Windows 10 Professional Edition
  • Oracle Database 12c Release 1

 

Flashback example scenario 1:

 

A new t_table1 table is created. Two data entries are inserted at a certain time point, and a data entry is inserted by mistake later. Now, you need to restore the status before the data is inserted by mistake.

 

Enable SQL Plus

Log on as a common user:

 

Create a new table t_table1:

Create table t_table1 (t_id number, t_name varchar2 (30 ));

Insert two pieces of data and submit:

Insert into t_table1 values (111, 'hui ');

Insert into t_table1 values (222, 'wq ');

Commit;

Insert a data entry at on March 13, April 2, 2016 by mistake:

Insert into t_table1 values (333, 'errordata ');

Commit;

 

Next we will restore the data before the error,

Query the data before the error is inserted. Because the data is inserted around on January 1, April 2, 2016, check the table status:

Select * from t_table1 as of timestamp to_timestamp ('2017-04-02 ', 'yyyy-mm-dd hh24: mi ');

Enable row migration:

Alter table t_table1 enable row movement;

Flash back:

Flashback table t_table1 to timestamp to_timestamp ('2017-04-02 ', 'yyyy-mm-dd hh24: mi ');

Check that the data has been restored.

 

Scenario 2:

 

Create a new table and drop the table by mistake. Now you need to restore the table.

 

Scenario 1: drop this table t_table1,

Flash back:

Flashback table t_table1 to before drop;

Verification:

 

RMAN example

 

Scenario:

 

After RMAN backup is enabled, database files (. DBF) are lost at the same time and data files are restored through RMAN.

 

Note:

Before RMAN backup/recovery, you must enable the database archiving function.

Under SQL Plus:

Stop the database before starting the archive:

Log on as an administrator:

Conn/as sysdba;

Stop database:

Shutdown immediate;

The database is started as mount:

Startup mount;

Start database Archiving:

Alter database archivelog;

Change the path of the archived log. Use the drive letter in windows:

Alter system set log_archive_dest_1 = "location = C: \ Users \ Public \ Documents \ arch ";

Open the database and check whether the archive is Enabled:

Alter database open;

Archive log list;

 

On the Windows console, enter the following command to Start RMAN:

Rman target/

Enable RMAN backup:

Backup database;

At this point, simulate accidental deletion of database files:

Close the database first:

Delete the. DBF file in the directory C: \ app \ orcl \ oradata \ orcl.

Restart RMAN:

RMAN target sys/

Restore database files using RMAN:

Data File recovered successfully:

Verification:

Start the database:

Startup;

Open SQL Plus and connect with a common user to verify whether the deleted data is restored:

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.