简体   繁体   中英

Converting db2 column names in select to be lowercase in json file

I currently have a very simple select that my code then dumps into JSON

SELECT user, phone
FROM table t;

But the select returns all uppercase column names, resulting in uppercase JSON keys, which I don't want. Is there a way in DB2 to return lowercase column names?

If you want to get lowercase columns names (not data) in DB2, you must use double quotes around the column names.

SELECT user as "user", phone as "phone"
FROM table t;

If you want the result of the query to be small, try this

SELECT LOWER(user), LOWER(phone)
FROM table t;

Use the LOWER() function;

    SELECT LOWER(user) AS 'user', LOWER(phone) AS 'phone'
    FROM table t;

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