简体   繁体   中英

SQL initcap on text[]

I am trying to uppercase all the words in an array of text in my table:

update locations
set aka  = initcap(aka) 

But initcap() doesn't support text arrays. How can I achieve the same effect?

Cast to text and back:

UPDATE locations
SET    aka = initcap(aka::text)::text[]
WHERE  aka IS DISTINCT FROM initcap(aka::text)::text[];

But don't touch rows that wouldn't change, to make it cheaper. See:

I assume you are aware the initcap() does not exactly "uppercase" strings. It...

Converts the first letter of each word to upper case and the rest to lower case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM