Paste this into a new question or an answer at dba.stackexchange.com:
<!-- --> > create table t ( a int, b int, c int, d int) ; > > <pre> > ✓ > </pre> <!-- --> > alter table t add unique(b, c); > > <pre> > ✓ > </pre> <!-- --> > insert into t (a, b, c, d) values (1, 1, 1, 1), (2, 2, null, 2), (3, 2, null, null); > > <pre> 3 rows affected > </pre> <!-- --> > select * from t; > > <pre> > a | b | c | d > -: | -: | ---: | ---: > 1 | 1 | 1 | 1 > 2 | 2 | <em>null</em> | 2 > 3 | 2 | <em>null</em> | <em>null</em> > </pre> *db<>fiddle [here](https://dbfiddle.uk/?rdbms=postgres_11&fiddle=34cab8ba7d74b488d215a96f7e83c096)*
back to fiddle