使用check 的一些限制

原文

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是在一块的。
官方截图

发布了19 篇原创文章 · 获赞 15 · 访问量 1091

猜你喜欢

转载自blog.csdn.net/qq_30396379/article/details/97934317