how to set maximum rows in create table for sqlite
In MySQL, I can use MAX_ROWS option in CREATE TABLE statement to limit rows number, how might I do this in sqlite? thanks
SQLite has no explicit mechanism for this, but you could implement it with a trigger:
CREATE TRIGGER MyTable_row_count BEFORE INSERT ON MyTable WHEN (SELECT COUNT(*) FROM MyTable) >= 10 BEGIN SELECT RAISE(FAIL, 'too many rows'); END;
SQLite has no such equivalent option.
Your best bet is to run SELECT COUNT(*) FROM tbl before inserting and checking if the returned count is greater than whatever you want your maximum to be.