1
votes

I have text column which has to be unique, but case insensitive. However I have to store text in original form (I can't transform it to lower/upper case). Is it possible in Postgres? Or I have to store two columns - one with original text and one (with unique index) transformed to lower case for example?

1

1 Answers

2
votes

You can do this using a functional index with either an upper or lower function.

eg.

CREATE UNIQUE INDEX ON table USING btree (lower(column_name));