Limit number of Rows inserted into a Table

核能气质少年 提交于 2020-02-16 05:13:46

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/17272583/limit-number-of-rows-inserted-into-a-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!