oracle 如何使oracle返回的结果集保留其列别名字符大小写

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5244142/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:59:14  来源:igfitidea点击:

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

javaoraclejdbcmetadataresultset

提问by Muhammad Hewedy

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

我正在尝试再次查询 oracle 数据库的一些 sql 语句。

I am using JavaResultSetMetaDatato get column alias names (through: rsmd.getColumnLable())

我使用JavaResultSetMetaData,以获得列别名(通过:rsmd.getColumnLable()

The query looks like:

查询如下所示:

select part_id partId, part_num partNumber from tbl;

select part_id partId, part_num partNumber from tbl;

But the result set meta-data returns for me the aliases as partidand partnumberrespectively ...

但是结果集元数据为我分别返回别名partidpartnumber...

But I need to get the aliases in the same characters case the user choose, so I need to get it as partIdand partNumberrespectively.

但是,我需要得到别名相同的字符情况下,用户选择,所以我需要得到它partIdpartNumber分别。

How to accomplish that?

如何做到这一点?

Thanks.

谢谢。

回答by J?rn Horstmann

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:

默认情况下,列名和别名不区分大小写,如果您想在 oracle 语句中保留大小写,您可以像这样引用名称:

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.

在我的测试中,列名在不使用引号时以大写形式返回,因此行为也可能取决于 jdbc 驱动程序的版本。