TRIGGER

Triggers: Who's Been Tampering With My Database?

The bible is essentially a read ony database. Users really shouldn't go around updating verses to suit their own purposes. So how about using MySQL's triggers to do a little snooping on anybody trying to tamper? The idea is anyone who attempts to update a row in the bible will have their change reported in the meddlers table.

First we'll create the meddlers table.

DROP TABLE IF EXISTS meddlers;

CREATE TABLE meddlers
(
  autokey INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
  user VARCHAR(255),
  `DATE` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

Syndicate content