Search code examples
sqlpostgresqlinsertcase-sensitivecase-insensitive

Sql insertion via insensitive unique key


I have a column on my table which has unique key property, but i also want it to be unique in an insensitive manner.What happens is if there is a key like xyz, insert statement with values Xyz,xYZ works properly, which I want to prevent. What can i use to achieve this? (I am using postgresql.)


Solution

  • I think you could do something like this:

    create unique index on tableName (lower(columnName))