加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – 在外键约束中MATCH FULL vs MATCH SIMPLE

发布时间:2020-12-13 16:19:40 所属栏目:百科 来源:网络整理
导读:我在phpPgAdmin中注意到MATCH SIMPLE或MATCH FULL选项,但我在 docs中找不到描述. 默认为MATCH SIMPLE.它们如何运作? 检查 CREATE TABLE page of the manual: There are three match types: MATCH FULL , MATCH PARTIAL ,and MATCH SIMPLE (which is the de
我在phpPgAdmin中注意到MATCH SIMPLE或MATCH FULL选项,但我在 docs中找不到描述.

默认为MATCH SIMPLE.它们如何运作?

检查 CREATE TABLE page of the manual:

There are three match types: MATCH FULL,MATCH PARTIAL,and MATCH SIMPLE
(which is the default). MATCH FULL will not allow one column of
a multicolumn foreign key to be null unless all foreign key columns
are null; if they are all null,the row is not required to have a
match in the referenced table. MATCH SIMPLE allows any of the foreign
key columns to be null; if any of them are null,the row is not
required to have a match in the referenced table. MATCH PARTIAL is not
yet implemented. (Of course,NOT NULL constraints can be applied to
the referencing column(s) to prevent these cases from arising.)

另外,在chapter on Foreign Keys:

Normally,a referencing row need not satisfy the foreign key
constraint if any of its referencing columns are null. If MATCH FULL
is added to the foreign key declaration,a referencing row escapes
satisfying the constraint only if all its referencing columns are null
(so a mix of null and non-null values is guaranteed to fail a MATCH FULL
constraint). If you don’t want referencing rows to be able to
avoid satisfying the foreign key constraint,declare the referencing
column(s) as NOT NULL.

请务必参考当前的手册. (或者与您的安装相匹配的版本.)不要过时的Google链接指向过时的版本.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读