Undo/Redo with SQLite


Undo/Redo with SQLite

This page demonstrates how to use triggers to implement undo/redo logic for an application that uses SQLite as its primary data structure.

The idea is to create a special table (named “undolog” in the example) that holds information needed to undo/redo changes to the database. For each table in the database that needs to participate in the undo/redo, triggers are created for each DELETE, INSERT, and UPDATE that cause entries to be made in undolog that will undo the operation. The entries in the undolog table consist of ordinary SQL statements that can be played back in order to accomplish the undo.

Related Posts