Alex's blog

More evil SQLite

Alexandra Lilith Lilly Martin

Published on

Here's some more evil use of SQLite.

CREATE TRIGGER sqlar_update
  INSTEAD OF UPDATE
    ON sqlar
  BEGIN
    -- ...
  END;

(Explanation: sqlar is the name of the table used for a SQLite Archive. Here I've implemented it as a view, rather than a table, and written INSTEAD OF triggers to translate UPDATEs, and INSERTs and DELETEs too, to the radically differently-arranged tables that the view pulls from. So my rather complex format should also as a side feature be accessible by the SQLite shell as an archive (or by the standalone sqlar program).)

Tagged: