0
我需要添加約束到表x
,它與其他表具有多對一的關係。所以表x
有字段other_table_id。Postgres添加唯一約束
表x
中還有一列叫做primary
,它是布爾類型。
我想確保每個other_table_id
有none or only one primary=true
。
多行可以有other_table_id
等於一些相同的價值和primary=false
但每other_table_id
只有一個true
。
如何創建此約束?