使用check 的一些限制

本文详细解析了Oracle数据库中CHECK约束的使用限制,包括条件必须为布尔表达式、禁止使用子查询、序列及特定函数等,帮助读者理解如何正确应用CHECK约束。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文

A CHECK constraint requires that a condition be true or unknown for every row of the table. If a statement causes the condition to evaluate to false, then the statement is rolled back. The condition of a CHECK constraint has these limitations:
The condition must be a Boolean expression that can be evaluated using the values in the row being inserted or updated.
The condition cannot contain subqueries or sequences.
The condition cannot include the SYSDATE, UID, USER, or USERENV SQL functions.
The condition cannot contain the pseudocolumns LEVEL or ROWNUM.
The condition cannot contain the PRIOR operator.
The condition cannot contain a user-defined function.

以上是从oracle官方文档copy出来的,是使用check的一些限制,黑色加粗的部分是限制。
主要是讲
1.check(条件)条件里的东西应当是boolean类型的,使用check的这一行应当能够使用这个条件判断对错。
2 。check(条件)条件里不能有子查询和序列
3. check(条件) 条件里不能有SYSDATE, UID, USER, USERENV 这些函数。
4. check(条件)条件里不能有伪列 rownum这些东西,这些不是创建表的时候的比较具体的东西。
5. 别用PRIOR
6. 别用用户自己定义的函数

prior Returns index that precedes specified index.在官方文档中,与exist是在一块的。
官方截图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值