dddh@gentoo64 ~ $ psql -U networks psql (9.6devel) Type "help" for help. networks=> create table test_01(a int, b int); CREATE TABLE networks=> create unique index test_01__a__b__uq on test_01(a, b); CREATE INDEX networks=> insert into test_01 values(1, 2); INSERT 0 1 networks=> insert into test_01 values(1, 3); INSERT 0 1 networks=> insert into test_01 values(1, 4); INSERT 0 1 networks=> insert into test_01 values(1); INSERT 0 1 networks=> insert into test_01 values(1); INSERT 0 1 networks=> insert into test_01 values(1); INSERT 0 1 networks=> insert into test_01 values(1); INSERT 0 1 networks=> insert into test_01 values(2, 1); INSERT 0 1 networks=> insert into test_01 values(2, 1); ERROR: duplicate key value violates unique constraint "test_01__a__b__uq" DETAIL: Key (a, b)=(2, 1) already exists. networks=> select * from test_01 order by 1, 2; a | b ---+--- 1 | 2 1 | 3 1 | 4 1 | 1 | 1 | 1 | 2 | 1 (8 rows) networks=>