简体   繁体   English

PostgreSQL +选择字段名称为大写和小写混合

[英]Postgresql + Select field name as upper and lowercase mixed

I am using this postgresql code, 我正在使用此PostgreSQL代码,

SELECT   id as DT_RowId , title 
FROM table_name  
ORDER BY  title asc  
LIMIT 25 OFFSET 0

The results returned like this. 这样返回结果。

        +--------+-----+
        |dt_rowid|title|
        +--------------+
        |  1     |A    |
        |  2     |B    |
        |  3     |C    |
        |  4     |D    |
        |  5     |E    |
        |  6     |F    |
        +--------+-----+

But i want results should return like this. 但我希望结果应该像这样返回。

        +--------+-----+
        |DT_RowId|title|
        +--------------+
        |  1     |A    |
        |  2     |B    |
        |  3     |C    |
        |  4     |D    |
        |  5     |E    |
        |  6     |F    |
        +--------+-----+

Note - DT_RowId field i want same like this(upper and lower case mixed). 注意-DT_RowId字段我想要这样(大写和小写混合)。

As explained in the manual unquoted identifier are folded to lowercase (which violates the SQL standard where unquoted identifiers should be folded to uppercase). 如手册中所述,未加引号的标识符被折叠为小写(这违反了SQL标准,在该标准中,未加引号的标识符应被折叠为大写)。

You need to use a quoted identifier in order to preserve the case: 您需要使用带引号的标识符以保留大小写:

SELECT id as "DT_RowId", 
       title 
FROM table_name  
ORDER BY  title asc  
LIMIT 25 OFFSET 0

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

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