! ! -.
CREATE TABLE meta (
`name` char(32) NOT NULL ,
`value_int` int ,
unique (name)
) ENGINE = INNODB;
insert into meta (name, value_int) values ('mytable.count', 0);
set delimiter |
CREATE TRIGGER mytablecountinsert AFTER INSERT ON mytable
FOR EACH ROW BEGIN
update meta set value_int=value_int+1 where name='mytable.count';
END;
|
CREATE TRIGGER mytablecountdelete AFTER DELETE ON mytable
FOR EACH ROW BEGIN
update meta set value_int=value_int-1 where name='mytable.count';
END;
|