Limit number of Rows inserted into a Table

2019-03-02 14:56发布

How can we restrict a table to have fixed number of rows? for example if i give Limit as 20, then 20 rows can be inserted into it and after that table should indicate the limit has been exceeded.

EXAMPLE: IF we create a trigger

 CREATE TRIGGER log AFTER INSERT ON TEST_TABLE
 BEGIN
 INSERT INTO TEST_TABLE VALUES(....);
 SELECT COUNT(COL) FROM TEST_TABLE;
 END;

This is not giving me the count as soon as i enter a row into the table.

标签: sql sqlite3
1条回答
劳资没心,怎么记你
2楼-- · 2019-03-02 15:07

Create a Trigger before Insert on That table. In Trigger you can check for count for records that same table has.

Check this link for Creating Trigger.

查看更多
登录 后发表回答