clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2555496 fiddles created (37441 in the last week).

CREATE TABLE t(id INT PRIMARY KEY, myColumn VARCHAR(100));
 hidden batch(es)


CREATE UNIQUE INDEX myIndex ON t((CASE WHEN myColumn <> 'myText' THEN myColumn END))
 hidden batch(es)


INSERT INTO t(id, myColumn) VALUES(1, 'myText'), (2, 'myText')
 hidden batch(es)


INSERT INTO t(id, myColumn) VALUES(3, 'aaaaa')
 hidden batch(es)


INSERT INTO t(id, myColumn) VALUES(4, 'aaaaa') -- Duplicate entry 'aaaaa' for key 'myIndex'
Duplicate entry 'aaaaa' for key 't.myIndex'
 hidden batch(es)


SELECT * FROM t
id myColumn
1 myText
2 myText
3 aaaaa
 hidden batch(es)