How to make the resultset returned from oracle keeps its column aliases characters case

南笙酒味 提交于 2020-01-14 08:52:27

问题


I am trying to querying some sql statment againest oracle database.

I am using Java ResultSetMetaData to get column alias names (through: rsmd.getColumnLable() )

The query looks like:

select part_id partId, part_num partNumber from tbl;

But the result set meta-data returns for me the aliases as partid and partnumber respectively ...

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.

How to accomplish that?

Thanks.


回答1:


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;

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.



来源:https://stackoverflow.com/questions/5244142/how-to-make-the-resultset-returned-from-oracle-keeps-its-column-aliases-characte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!