您好,欢迎访问一九零五行业门户网

Oracle如何恢复误删除的表的数据?

由于不小心误删除oracle的表的数据,这些数据可能很重要,如何快速恢复,让主管不发现,可写一个存储过程,恢复删除数据的前某一
由于不小心误删除oracle的表的数据,这些数据可能很重要,如何快速恢复,让主管不发现,可写一个存储过程,,恢复删除数据的前某一时刻的数据
create or replace procedure pro_recover_del_data(
ai_table_name in varchar2, --误删除的数据的表名称
ai_data_time in varchar2,  --恢复到删除数据前的某一时间点
ao_success out varchar2,   --是否成功 1:成功,0:失败
op_msg  out varchar2    --提示信息
)
authid current_user
is
    sqlstring varchar2(1000);
begin
delete from rela_t_relaset;
    sqlstring:='insert into ' || ai_table_name || ' select * from '|| ai_table_name || ' as of timestamp to_timestamp('|| ''''
             || ai_data_time || '''' ||','||''''  || 'yyyy-mm-dd hh24:mi:ss '|| '''' || ')';
   execute immediate sqlstring;
  commit;
  op_msg:='恢复成功!';
  ao_success:='1';
exception
  when dup_val_on_index then
         op_msg:='主键重复';
    when timeout_on_resource then
         op_msg:='等待资源超时';
    when invalid_cursor then
         op_msg:='无效的游标 ';
    when not_logged_on then
         op_msg:='没有连接到数据库';
    when login_denied then
         op_msg:='用户名/口令错误';
    when no_data_found then
         op_msg:='select into没有找到数据';
    when too_many_rows then
         op_msg:='select into 返回多行数据';
    when zero_divide then
         op_msg:='试图被零除';
    when invalid_number then
         op_msg:='转换一个数字失败';
    when storage_error then
         op_msg:='内存不够引发的内部错误';
    when program_error then
         op_msg:='内部错误';
    when value_error then
         op_msg:='转换或截断错误';
    when rowtype_mismatch then
         op_msg:='主游标变量与 pl/sql变量有不兼容行类型';
    when cursor_already_open then
         op_msg:='试图打开一个已存在的游标';
    when access_into_null then
         op_msg:='试图访问一个空值';
    when collection_is_null then
         op_msg:='访问一个空集合';
    when subscript_outside_limit then
         op_msg:='试图将exists 以外的集合( collection)方法应用于一个null pl/sql 表上或varray上';
    when subscript_beyond_count then
         op_msg:='对嵌套或varray 索引得引用大于集合中元素的个数';
    when others then
         op_msg:='发生其它错误!';
rollback;
        ao_success:='0';
end;
然后调用该存储过程即可。
其它类似信息

推荐信息