How do I create an index in PostgreSQL based on lowercase only?

You can create the index and transform the field to upper- or lower-case. Then when you do your queries, you can do the same transform and it’ll do the right thing.

So:

CREATE UNIQUE INDEX lower_case_username ON users ((lower(username)));

Then query for the same thing:

SELECT username FROM users WHERE lower(username) = 'bob';

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)