Select Flashback Query
Description
Oracle
The flashback query claused in Oracle retrieves past data from a table, view, or materialized view. In Oracle, the uses can include:
Restoring deleted data or undoing an incorrect commit, comparing current data with the corresponding data at an earlier time, checking the state of transactional data at a particular time, and reporting generation tools to past data, among others. (Oracle Flashback query documentation).
Snowflake
The equivalent mechanism in Snowflake to query data from the past is the AT | BEGIN
query. Notice that the only equivalent is for the AS OF
statements.
Furthermore, Snowflake has complete "Time Travel" documentation that allows querying data to clone objects such as tables, views, and schemas. There are limitations on the days to access the past or deleted data (90 days before passing to Fail-safe status). For more information, review the Snowflake Time Travel Documentation.
Oracle syntax
Snowflake Syntax
Notice that the query ID must reference a query executed within 14 days. If the query ID references a query over 14 days old, the following error is returned: Error: statement <query_id> not found
. To work around this limitation, use the time stamp for the referenced query. (Snowflake AT | Before documentation)
Sample Source Patterns
The following data is used in the following examples to generate the query outputs.
1. AS OF with TIMESTAMP case
Oracle
Snowflake
2. AS OF with SCN case
Oracle
Snowflake
Known Issues
1. The option when it is using SCN is not supported.
2. The VERSION statement is not supported in Snowflake.
Related EWIS
Last updated