43

I'm using PostgreSQL 9.1 and I have a users table with a login column.

login names are case-sensitive, for example Bob, MikE, john. I would like to transform all these records into lowercase. How can I do that?

1 Answer 1

59

You can do this:

UPDATE table_name SET column=lower(column)

Refer to www.postgresql.org/docs/9.1/static/functions-string.html

2
  • 3
    And if you'd like to know how many rows were affected, a simple UPDATE table_name SET column = LOWER(column) WHERE column != LOWER(column); will do. Mar 28, 2018 at 13:38
  • I get this error HINT: No function matches the given name and argument types. You might need to add explicit type casts. while trying this.
    – Surya
    Oct 11, 2019 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.