Home Products QA Support Contact

How do I create a case insenstive index in Postgresql

CREATE INDEX tab_index ON tab (lower(col))

Say I had a table users with a username column that I wanted to be unique for both upper and lowercase versions of the name.

CREATE unique INDEX users_username ON users(lower(username))