Home > Database > Mysql Tutorial > body text

SCN FlashBack 闪回常用语句

WBOY
Release: 2016-06-07 17:13:27
Original
1377 people have browsed it

可以通过函数SCN_TO_TIMESTAMP(10g以后)将其转换回timestamp: select dbms_flashback.get_system_change_number, SCN_TO_TIME

可以通过函数SCN_TO_TIMESTAMP(10g以后)将其转换回timestamp:

select dbms_flashback.get_system_change_number, SCN_TO_TIMESTAMP(dbms_flashback.get_system_change_number) from dual;

也可以用函数timestamp_to_scn将一个timestamp转换为SCN:

select timestamp_to_scn(SYSTIMESTAMP) as scn from dual;

如果你想把DATE类型转换成TIMESTAMP类型,就使用CAST函数。

select cast(sysdate as timestamp) from dual;

--恢复到几分钟前
select t.*, t.rowid from ar_mid_acap as of timestamp sysdate - 5 / 1440 t;

--恢复到具体的某个时间点
select *
  from ar_mid_acap as of scn timestamp_to_scn(To_Date('2012-4-25', 'yyyy-mm-dd hh24:mi:ss'));

--两个时间点间的变化信息
select v_id, va, versions_startscn, versions_endscn, versions_operation
  from t_fb_test versions between scn 12372466 and 12372538
 order by 1;

--恢复语句undo
select xid, commit_scn, commit_timestamp, operation, undo_sql
  from flashback_transaction_query q
 where q.xid in
       (select versions_xid
          from t_fb_test versions between scn 23413946 and 23413959);

--恢复表
 FLASHBACK TABLE goodsinfo1 TO BEFORE DROP;

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!