在postgres中的两个表数据上创建组合唯一索引

时间:2018-01-12 18:54:47

标签: sql postgresql indexing

我试图在两个表数据的基础上创建连接索引。下面两个表有一对一的关系。如果有一条记录记录,其中访客值为true,则为contact_tbl中的移动设备。 我在contact_tbl(customer_id,mobile和type)上创建了唯一索引,但我希望这个唯一索引应该是在profile_tbl中guest是false。

如下例所示,不应插入id - 4.

profile_tbl  
id  guest  
1   true  
2   true  
3   false  
4   false  
contact_tbl  
id customer_id mobile type  
11   1    545454  1  
12   2    545454  1    
13   3    123541  1   
14   4    123541  1  

0 个答案:

没有答案
相关问题