By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE FUNCTION
CREATE TABLE
INSERT 0 3
CREATE TABLE
INSERT 0 3
| data_id | col1 | col2 | uniq_hash |
|---|---|---|---|
| 1 | foo | bar | 7ea22296-b1b2-1630-e534-8536e8372e6f |
| 2 | foo | baz | f0973580-535c-81b3-691c-3cec29806457 |
| 3 | baz | null | c32b26c3-7d9d-86bf-cbb7-ca9e3c2fecc9 |
SELECT 3
| day | data_id |
|---|---|
| Mon | 1 |
| Tue | 1 |
| Wed | 2 |
SELECT 3
ERROR: duplicate key value violates unique constraint "data_bighash_uni" DETAIL: Key (uniq_hash)=(c32b26c3-7d9d-86bf-cbb7-ca9e3c2fecc9) already exists.
| data_id | day | col1 | col2 | uniq_hash |
|---|---|---|---|---|
| 1 | Mon | foo | bar | 7ea22296-b1b2-1630-e534-8536e8372e6f |
| 1 | Tue | foo | bar | 7ea22296-b1b2-1630-e534-8536e8372e6f |
| 2 | Wed | foo | baz | f0973580-535c-81b3-691c-3cec29806457 |
SELECT 3