【问题标题】:Oracle ROLLBACK not returning dataOracle ROLLBACK 不返回数据
【发布时间】:2014-10-22 02:01:00
【问题描述】:

我在删除数据时犯了一个错误。删除后我没有运行commit语句,但是运行ROLLBACK的时候,数据还是丢失了。

我跑了类似的东西:

create table temp_ids as
select myid ABC --This might be part of the mistake as I did not alias this to my_id
from XX WHERE xx;
create index idx01 on temp_ids (my_id);

delete from YYY where my_id in (select my_id from temp_ids);
delete from XXX where my_id in (select my_id from temp_ids);
delete from ZZZ where my_id in (select my_id from temp_ids);
commit;

我使用的是 sqldeveloper,在前 2 次删除后(在提交之前)我点击了取消查询按钮。但回滚不会返回前 2 个表中的数据。
还有其他选择吗?
我正在使用 Oracle Database 11g 版本 11.2.0.3.0 - 64 位生产

更新:

~~~~~~~

根据要求,这里是完整的声明:

create table temp_events as
select 
DUP.Event_ID Dupl
from EVENT_REV MASID INNER JOIN EVENTS MAS ON MASID.Event_ID = MAS.Event_ID
left join EVENTS DUP
ON 
MAS.IMPACT = DUP.IMPACT AND  
INNER JOIN EVENT_REV DUPID ON DUPID.Event_ID = DUP.Event_ID 
WHERE 
MAS.person_id = 'JSteward'
ORDER BY MAS.event_id;
create index idx01 on temp_events(event_id);

delete from EVENT_REV where event_id in (select event_id from temp_events);
delete from EVENT_TASKS where event_id in (select event_id from temp_events);
--Here is where I hit the Cancel Query button and ran ROLLBACK.
delete from TIMESHEETS where event_id in (select event_id from temp_events);
delete from TRIPS where event_id in (select event_id from temp_events);
commit;

temp_events 表有大约 800 条记录,例如: C00156 C45568 C41155 D12355

【问题讨论】:

  • 你确定数据一开始就在那里吗?您能否提供一个包含一些示例数据的完整示例?
  • 是的,首先肯定有数据。完整的示例可能会使问题有点复杂,但无论如何我都会这样做。
  • 而且你也确定SqlDeveloper(Preferences/Database/Advanced)中的Autocommit功能也没有开启?
  • 脚本输出窗口显示了什么?大概你在同一个会话中回滚,没有断开连接?如果发生了摩擦,您是否启用了闪回?例如select * from event_rev as of timestamp <some time before the delete> 可能会向您显示数据并允许您检索它?
  • 自动提交未启用。它仍然在同一个会话中。我仍然开着窗户,还没有断开连接。脚本窗口显示:234,084 行已删除。删除了 75,440 行。从行开始的错误:命令中的 28 - 从 TIMESHEET 中删除,其中 event_id 在(从 temp_events 中选择 event_id) 命令行错误:28 列:1 错误报告 - SQL 错误:ORA-01013:用户请求取消当前操作 01013。00000 - “用户请求取消当前操作”

标签: oracle commit rollback


【解决方案1】:

以下解决方案对我有用。谢谢亚历克斯普尔。

我运行了以下命令,它实际上用数据填充了新表:

Create table EVENT_REV_RESTORE AS 
select * from EVENT_REV
AS OF TIMESTAMP
   TO_TIMESTAMP('2014-08-28 10:00:00', 'YYYY-MM-DD HH:MI:SS');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-09
    • 1970-01-01
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 2011-09-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多