限制插入到表中的行数 [英] Limit number of Rows inserted into a Table

查看:24
本文介绍了限制插入到表中的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何限制一个表的行数是固定的?例如,如果我将 Limit 设为 20,则可以将 20 行插入其中,然后该表应指示已超出限制.

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.

推荐答案

在插入那个之前创建触发器.在触发器中,您可以检查同一个表中的记录计数.

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.

这篇关于限制插入到表中的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆