Can I have a trigger to check any insert or update on whole database?
I tried this but it didn't work:
create trigger updateHistory after insert on database
Can I have a trigger to check any insert or update on whole database?
I tried this but it didn't work:
create trigger updateHistory after insert on database
Yaou need to elaborate the database
into separate tables. And give the action. Eg:
CREATE TRIGGER updatehistory
BEFORE UPDATE ON `table,table2`
FOR EACH ROW
BEGIN
INSERT INTO
SET action = 'insert',
record = OLD.record,
changedat = NOW();
END
And as answered here, you cannot create both insert
and update
at the same trigger, but you can move the common code into a procedure and have them both call the procedure.