Track Table Changes with Flashback Time Travel

Use Flashback Time Travel to view past states of database objects or to return database objects to a previous state without using point-in-time media recovery.

About Flashback Time Travel

Flashback Time Travel lets you track and store transactional changes to a table over its lifetime. Flashback Time Travel is useful for compliance with record stage policies and audit reports. You can also use Flashback Time Travel in various scenarios such as enforcing digital shredding, accessing historical data, and selective data recovery.

Flashback Time Travel was called Flashback Data Archive in previous Oracle AI Database versions. The Flashback Time Travel APIs and some Flashback Time Travel terms such as the FLASHBACK ARCHIVE privilege retain the Flashback Data Archive naming.

Each Autonomous AI Database instance has one Flashback Archive named flashback_archive that supports Flashback Time Travel operations. The default retention time for flashback_archive is 60 days. See Modify the Retention Time for Flashback Time Travel for information on changing the default retention time.

There are restrictions to enable Flashback Time Travel for a table, including the following:

See Notes for Flashback Time Travel for a list of additional Flashback Time Travel restrictions.

See Using Oracle Flashback Technology for more information on Flashback Technology.

Enable Flashback Time Travel for a Table

Describes steps to enable Flashback Time Travel for a table in Autonomous AI Database.

By default, Flashback Time Travel is disabled for new and existing tables.

The following is the prerequisite to enable Flashback Time Travel:

You can enable Flashback Time Travel for an existing table or a new table that you are creating.

  1. To enable Flashback Time Travel when you create a table:

    CREATE TABLE employee (EMPNO NUMBER(4) NOT NULL, ENAME VARCHAR2(10), JOB VARCHAR2(9), MGR NUMBER(4)) FLASHBACK ARCHIVE;
  2. To enable the Flashback Time Travel for an existing table:

    ALTER TABLE departments FLASHBACK ARCHIVE;

After you enable Flashback Time Travel for a table you can disable Flashback Time Travel. See Disable Flashback Time Travel for a Table for more information.

Disable Flashback Time Travel for a Table

Describes procedure to disable Flashback Time Travel for a table in Autonomous AI Database.

After Flashback Time Travel is enabled for a table you can disable it as the ADMIN user or if you have the FLASHBACK ARCHIVE object privilege.

For example, to disable Flashback Time Travel for the employee table:

ALTER TABLE employee NO FLASHBACK ARCHIVE;

Modify the Retention Time for Flashback Time Travel

Describes procedure to modify the retention time for Flashback Time Travel in Autonomous AI Database.

You can modify the retention time for Flashback Time Travel if you are logged in as ADMIN user or if you have EXECUTE privilege on DBMS_CLOUD_ADMIN.

For example, to set the retention time to 365 days:

BEGIN
  DBMS_CLOUD_ADMIN.SET_FLASHBACK_ARCHIVE_RETENTION
   (retention_days => 365);
END;
/

See SET_FLASHBACK_ARCHIVE_RETENTION Procedure for detailed information about the procedure.

Purge Historical Data for Flashback Time Travel

Describes procedure to purge historical data for Flashback Time Travel in Autonomous AI Database.

You can purge historical data for Flashback Time Travel if you are logged in as the ADMIN user or if you have EXECUTE privilege on DBMS_CLOUD_ADMIN.

For example, to purge all Flashback Time Travel historical data:

BEGIN
  DBMS_CLOUD_ADMIN.PURGE_FLASHBACK_ARCHIVE
   (scope => 'ALL');
END;
/

Example to purge the historical Flashback Time Travel data before a specified timestamp:

BEGIN
  DBMS_CLOUD_ADMIN.PURGE_FLASHBACK_ARCHIVE
   (scope => 'TIMESTAMP', before_timestamp => '12-JUL-2023 10:24:00');
END;
/

Example to purge Flashback Time Travel historical data older than 1 day:

BEGIN
  DBMS_CLOUD_ADMIN.PURGE_FLASHBACK_ARCHIVE
   (scope => 'TIMESTAMP', before_timestamp => SYSTIMESTAMP - INTERVAL '1' DAY);
END;
/

Example to purge the historical Flashback Time Travel data before the specified scn:

BEGIN
  DBMS_CLOUD_ADMIN.PURGE_FLASHBACK_ARCHIVE
   (scope => 'SCN',before_scn=> '5928826');
END;
/

See PURGE_FLASHBACK_ARCHIVE Procedure for detailed information about the procedure.

View Flashback Time Travel Information

Describes data dictionary views to view information about Flashback Time Travel files in Autonomous AI Database.

You can view information about Flashback Time Travel files in static data dictionary views.

View Description
*_FLASHBACK_ARCHIVE Displays information about Flashback Time Travel files.
*_FLASHBACK_ARCHIVE_TS Displays tablespaces of Flashback Time Travel files.
*_FLASHBACK_ARCHIVE_TABLES Displays information about tables that have Flashback Time Travel enabled.

Notes for Flashback Time Travel

Provides notes and restrictions for using Flashback Time Travel on Autonomous AI Database.

Note the following Flashback Time Travel restrictions: