Oracle

Oracle:使用帶有表別名的“as of”子句?

  • September 14, 2018

我可以毫無問題地執行這個閃回查詢:

select x from a as of timestamp sysdate;

但是,如果我使用表別名,則會出現錯誤。

select foo.x from a foo as of timestamp sysdate;
ORA-00933: SQL command not properly ended

如何將“as of”與表別名一起使用?

表別名跟在“as of”子句之後。

select x from a as of timestamp sysdate foo;

作為擴展,如果您要加入多個表,您可以根據需要從不同時間加入它們(不知道您為什麼想要,但是……)

select *
from a as of timestamp sysdate-1 foo
join b as of timestamp sysdate-2 fi on foo.name = fi.name;

引用自:https://dba.stackexchange.com/questions/123212