本文介绍了查找SQL约束:SELECT COUNT(*)from tBoss< 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想限制表中的条目。让我们说在 tBoss 表中。是否有SQL约束检查表中当前有多少个元组?喜欢
I'd like to limit the entries in a table. Let's say in table tBoss. Is there a SQL constraint that checks how many tuples are currently in the table? Like
SELECT COUNT(*) from tBoss < 2
Firebird说:
Firebird says:
Norbert
推荐答案
您的数据库有触发器吗?如果是,添加一个触发器,回滚将添加超过2行的任何插入...
Does your database have triggers? If so, Add a trigger that rolls back any insert that would add more than 2 rows...
Create Trigger MyTrigName
For Insert On tBoss
As
If (Select Count(*) From tBoss) > 2
RollBack Transaction
但是为了直接回答你的问题,你想要的谓词将select子查询放在括号中。像这样...
but to answer your question directly, the predicate you want is to just put the select subquery inside parentheses. like this ...
[First part of sql statement ]
Where (SELECT COUNT(*) from tBoss) < 2
这篇关于查找SQL约束:SELECT COUNT(*)from tBoss< 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!