Quick Response 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 _

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 _

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 Reply 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;
In this way, the deleted data can be returned 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.

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.