我们的PostgreSQL 11数据库有表A和表B.
postgres=# \d A;
Table "public.A"
Column | Type | Collation | Nullable | Default
---------------------+-----------------------------+-----------+----------+---------
id | bigint | | not null |
b_id | bigint | | not null |
Indexes:
"a_pkey" PRIMARY KEY, btree (id)
"idx_a_bid" btree (b_id)
Foreign-key constraints:
"fk_a_bid" FOREIGN KEY (b_id) REFERENCES A(id)
postgres=# select count(*) from A where b_id = 522039;
count
-------
90
(1 row)
postgres=# select count(*) from B where id = 522039;
count
-------
0
(1 row)
似乎有一个从a.b_id到b.id的非强制FK.
这些表上的触发器从未被禁用(因此在理论上已经应用了FK判断).
除了过go 有人禁用触发器并从B中删除行之外,还有什么原因可以解释这一点?