我正在尝试创建一个表,该表将强制执行两个相同类型的两个列的唯一组合 - 在两个方向上.例如,这将是非法的:
col1 col2
1 2
2 1
Run Code Online (Sandbox Code Playgroud)
我想出了这个,但它不起作用:
database=> \d+ friend;
Table "public.friend"
Column | Type | Modifiers | Storage | Stats target | Description
--------------+--------------------------+-----------+----------+--------------+-------------
user_id_from | text | not null | extended | |
user_id_to | text | not null | extended | |
status | text | not null | extended | |
sent | timestamp with time zone | not null | plain | |
updated | timestamp with time zone | | plain …Run Code Online (Sandbox Code Playgroud)