如何使从oracle返回的结果集保持其列别名字符大小写 [英] How to make the resultset returned from oracle keeps its column aliases characters case
问题描述
我正在尝试再次查询一些sql语句oracle数据库.
I am trying to querying some sql statment againest oracle database.
我正在使用Java
ResultSetMetaData
来获取列别名(通过:rsmd.getColumnLable()
)
I am using Java
ResultSetMetaData
to get column alias names (through: rsmd.getColumnLable()
)
查询如下:
select part_id partId, part_num partNumber from tbl;
但是结果集元数据为我返回的别名分别为partid
和partnumber
...
But the result set meta-data returns for me the aliases as partid
and partnumber
respectively ...
但是我需要使用用户选择的相同字符来获取别名,因此我需要分别以partId
和partNumber
来获取别名.
But I need to get the aliases in the same characters case the user choose, so I need to get it as partId
and partNumber
respectively.
如何做到这一点?
谢谢.
推荐答案
默认情况下,列名和别名不区分大小写,如果要在oracle语句中保留大小写,可以使用如下名称:
Column names and aliases are case insensitive by default, if you want to preserve case in an oracle statement you could quote the names like this:
select part_id "partId", part_num "partNumber" from tbl;
在我的测试中,当不使用引号时,列名以大写形式返回,因此该行为也可能取决于jdbc驱动程序的版本.
In my tests the column names where returned in uppercase when not using the quotes, so the behaviour might also depend on the version of the jdbc driver.
这篇关于如何使从oracle返回的结果集保持其列别名字符大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!