简体   繁体   English

将select中的db2列名称转换为json文件中的小写

[英]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我目前有一个非常简单的选择,我的代码然后转储到 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.但是 select 返回所有大写的列名,导致我不想要的大写 JSON 键。 Is there a way in DB2 to return lowercase column names? DB2 中有没有办法返回小写的列名?

If you want to get lowercase columns names (not data) in DB2, you must use double quotes around the column names.如果您想在 DB2 中获得小写的列名(不是数据),您必须在列名周围使用双引号。

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;使用 LOWER() 函数;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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