initially immediate 初始化立即执行.
initially deferred 初始化延迟执行.
表约束定义:
[ CONSTRAINT name ] { PRIMARY KEY constraint | FOREIGN KEY constraint | UNIQUE constraint | CHECK constraint } [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] [ [ NOT ] DEFERRABLE ]
列约束定义:
[ CONSTRAINT name ] { NOT NULL constraint | PRIMARY KEY constraint | FOREIGN KEY constraint | UNIQUE constraint | CHECK constraint } [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] [ [ NOT ] DEFERRABLE ]
一个 CONSTRAINT (约束)定义可以包含一个任意顺序的延迟属性的子句和/或一个初始化约束式子句.
NOT DEFERRABLE
意味着每条 SQL 语句执行后都必须校验是否违反约束规则.
DEFERRABLE
意味着约束的校验可以推迟到晚些时候,但不晚于当前事务的结束.
事务开始时,每个约束会为每个约束的模式设置一个初始值.
INITIALLY IMMEDIATE
意味着,当事务开始时,每个 SQL 语句执行后都必须检查是否违反了约束规则.
INITIALLY DEFERRED
意味着,当事务开始后,对约束的检查可以推迟到晚些时候,但不晚于当前事务的结束.