add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
create table test(txt text);
alter table test
add constraint case_insensitive_unique
exclude using gist(upper(txt) with =);
CREATE TABLE
ALTER TABLE
insert into test(txt) select 'hello';
INSERT 0 1
insert into test(txt) select 'Hello';
ERROR:  conflicting key value violates exclusion constraint "case_insensitive_unique"
DETAIL:  Key (upper(txt))=(HELLO) conflicts with existing key (upper(txt))=(HELLO).
alter table test drop constraint case_insensitive_unique;
ALTER TABLE
CREATE UNIQUE INDEX UniqueValue ON test (UPPER(txt));
CREATE INDEX
insert into test(txt) select 'Hello';
ERROR:  duplicate key value violates unique constraint "uniquevalue"
DETAIL:  Key (upper(txt))=(HELLO) already exists.
insert into test(txt) select 'heLLo';
ERROR:  duplicate key value violates unique constraint "uniquevalue"
DETAIL:  Key (upper(txt))=(HELLO) already exists.
table test;
txt
hello
SELECT 1