OBCP教材中的AS OF SCN闪回查询语句有错误,需要先使用to_timestamp进行转换才行

OBCP教材中的AS OF SCN闪回查询语句有错误,需要先使用to_timestamp进行转换才行

2 个赞

是不是nls_format设置和sql里的不一致

1 个赞

会话日期格式调整下试试

SET SESSION nls_date_format='YYYY-MM-DD HH24:MI:SS';
SET SESSION nls_timestamp_format='YYYY-MM-DD HH24:MI:SS.FF';
SET SESSION nls_timestamp_tz_format='YYYY-MM-DD HH24:MI:SS.FF';

-- 分别做闪回查询(两种语法均可)
select * from t1 as of timestamp to_timestamp('2025-05-07 13:35:09','YYYY-MM-DD HH24:MI:SS');
select * from t1 as of scn timestamp_to_scn('2025-05-07 13:35:09'); 
+------+------+------+
| ID   | NAME | AGE  |
+------+------+------+
|    1 | A    |   10 |
+------+------+------+

select * from t1 as of timestamp to_timestamp('2025-05-07 13:35:20','YYYY-MM-DD HH24:MI:SS');
select * from t1 as of scn timestamp_to_scn('2025-05-07 13:35:20'); 
+------+------+------+
| ID   | NAME | AGE  |
+------+------+------+
|    1 | A    |   10 |
|    2 | B    |   20 |
+------+------+------+

select * from t1 as of timestamp to_timestamp('2025-05-07 13:35:30','YYYY-MM-DD HH24:MI:SS');
select * from t1 as of scn timestamp_to_scn('2025-05-07 13:35:30'); 
+------+------+------+
| ID   | NAME | AGE  |
+------+------+------+
|    1 | A    |   10 |
|    2 | B    |   20 |
|    3 | C    |   30 |
+------+------+------+
1 个赞