0

I'm using phpMyAdmin and I want to set the capacity of a table so it can only store 150 rows. Is this possible? My table is InnoDB.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

This is not possible without using a trigger.

Answer taken from here.

DELIMITER $$

CREATE TRIGGER trigger1
BEFORE INSERT
ON table1
FOR EACH ROW
BEGIN
  SELECT COUNT(*) INTO @cnt FROM table1;
  IF @cnt > 150 THEN
    CALL sth(); -- raise an error
  END IF;
END
$$

DELIMITER ;
Community
  • 1
  • 1
rick6
  • 467
  • 3
  • 8