2

如何闪回表中所有行的特定列?

例如,给定这张表:

select * from t as of scn 1201789714628;
a b 
- - 
x 1 
y 2 
z 3 
select * from t;
a b 
- - 
x 4 
y 5 
z 6 

我可以闪回特定行中的列,如下所示:

update t set b = (select b from t as of scn 1201789714628 where a='x') where a='x';
select * from t;
a b 
- - 
x 1 
y 5 
z 6 

但我无法弄清楚将所有行的 b 设置为其先前值的语法。

update t t1 set b = (select b from t as of scn 1201789714628) t2 where t1.a = t2.a;
Error at Command Line:11 Column:60
SQL Error: ORA-00933: SQL command not properly ended
4

1 回答 1

3

你可以试试这个:

update t t1 
  set b = (select b from (select a, b from t as of scn 1201789714628) t2
           where t1.a = t2.a);

PS 如果您现在不打算更新它,我建议您将快照复制到临时表中(它很快就会消失)。

于 2014-11-12T07:53:49.283 回答