Detailed description of restoration after Oracle accidentally deletes table data

Source: Internet
Author: User
1. query and modify the undo_retention parameter: run the showparameterundo command to view the undo_retention settings of the database at that time. Shown as follows: undo_man

1. query and modify the undo_retention parameter: run the show parameter undo command to view the current database parameter undo_retention settings. Shown as follows: undo_man

1. query and modify the undo_retention parameter:

Run the show parameter undo command to view the current database parameter undo_retention settings.

Shown as follows:

Undo_management string AUTO
Undo_retention integer 10800
Undo_suppress_errors boolean FALSE
Undo_tablespace string UNDOTBS1

Undo_retention (hold power). The Unit is 10800 seconds. That is, 3 hours.

Modify the default undo_retention parameter settings:

Alter system set undo_retention = 10800 SCOPE = BOTH;

Ii. Quick recovery after Oracle accidentally deletes table data:

[Method 1 ]:
With the flash back feature provided by oracle:
Exec dbms_flashback.enable_at_time (to_date ('2017-07-23 10:21:00 ', 'yyyy-mm-dd hh24: mi: ss '));

Set serveroutput on
DECLARE r_temp hr. job_history % ROWTYPE;
CURSOR c_temp is select * FROM hr. job_history;
BEGIN
OPEN c_temp;
Dbms_flashback.disable;
LOOP
FETCH c_temp INTO r_temp;
Exit when c_temp % NOTFOUND;
Insert into hr. job_history (EMPLOYEE_ID, JOB_ID, START_DATE, END_DATE) values (r_temp.EMPLOYEE_ID, r_temp.JOB_ID, r_temp.START_DATE, r_temp.END_DATE );
Commit;
End loop;
CLOSE c_temp;
END;
This method can recover the deleted data to the corresponding table. First, ensure that the user has the permission to execute the dbms_flashback package.

Method 2 ]:
Insert into hr. job_history
Select * from hr. job_history as of timestamp to_timestamp ('2017-07-23 10:20:00 ', 'yyyy-mm-dd hh24: mi: ss ');
This method is simple and easy to grasp. The function is the same as the above time as the time before your misoperation, preferably close to the misoperation, because the time limit for oracle data stored in the rollback persistence segment is determined by the value of the undo_retention parameter.

SQL> col fscn for 99999999999999999sql> col nscn for 9999999999999999999SQL> select name, FIRST_CHANGE # fscn, NEXT_CHANGE # nscn, FIRST_TIME from v $ archived_log ;................... NAMEFSCNNSCN FIRST_TIME was too large/mwarch/oracle/14:38:28/mwarch/oracle/14:38:32/mwarch/oracle/14:38:35/mwarch/oracle/14:38:38/mwarch/oracle/mwarch /oracle/Jun 14:38:41/mwarch/oracle/Jun 14:38:44/mwarch/oracle/Jun 14:38:45/mwarch/oracle/Jun 14:46:05/mwarch/oracle/Jun 14:46:08/mwarch/oracle/Jun/mwarch /oracle/route 52422.dbf129299508425929951751 14:46:11/mwarch/oracle/route 14:46:14 ................... /mwarch/oracle/Jun 15:55:57/mwarch/oracle/Jun 52499.dbf1293013921212930139446 15:55:59/mwarch/oracle/Jun 15: 56: 00 NAMEFSCNNSCN FIRST_TIME was too large/mwarch/oracle/15:56:02/mwarch/oracle/15:56:03/mwarch/oracle/15:56:05/mwarch/oracle/15:56:05/mwarch/oracle/ mwarch/oracle/201752505.dbf1293014061012930140845 2005-06-22 15: 56: 0714811 rows selected.

,

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.