Postgresql查询会自动将大写名称转换为小写
postgresql查询自动将大写的名称转换为小写的案例,希望对大家有所帮助。一起跟随小编过来看看吧
我就废话不多说了,大家还是直接看代码吧~
SELECT sum(aa) as "recordNumber" FROM table
SELECT sum(aa) as recordNumber FROM table
postgis查询字段是将字段字段转为小写,如果需要大写的字符,需要加双引号
补充:Postgresql中表名、列名、用户名大小写问题
注意:是双引号,单引号可能会被解析成普通字符,因而是不识别的字段
highgo=# create table "ExChange" (id int); CREATE TABLE highgo=# create table ExChange (id int); CREATE TABLE highgo=# d List of relations Schema | Name | Type | Owner ----------------+----------+-------+-------- oracle_catalog | dual | view | highgo public | ExChange | table | highgo public | exchange | table | highgo public | myt | table | highgo public | t1 | table | highgo public | tran | table | highgo (6 rows)
highgo=# insert into exchange values (1); INSERT 0 1 highgo=# insert into "ExChange" values (2); INSERT 0 1
highgo=# select * FROM exchange ; id ---- 1 (1 row) highgo=# select * FROM ExChange ; id ---- 1 (1 row)
highgo=# select * FROM "ExChange" ; id ---- 2 (1 row)
highgo=# insert into ExChange values (2); INSERT 0 1 highgo=# select * FROM "ExChange" ; id ---- 2 (1 row)
highgo=# select * FROM exchange ; id ---- 1 2 (2 rows)
> 从上面可以看出,如果不加双引号,那么表名都会被转化为小写。如果想要大小写混用,需要添加双引号。
highgo=# create table exchange (ID int,id int); ERROR: 42701: column "id" specified more than once highgo=# create table exchange (ID int,name text); CREATE TABLE highgo=# select id from exchange ; id ---- (0 rows)
highgo=# select ID from exchange ; id ---- (0 rows)
highgo=# select "ID" from exchange ; ERROR: 42703: column "ID" does not exist LINE 1: select "ID" from exchange ;
highgo=# d exchange Table "public.exchange" Column | Type | Modifiers --------+---------+----------- id | integer | name | text |
highgo=# du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- aaa | | {} gpadmin | Superuser, Create role, Create DB | {} highgo | Superuser, Create role, Create DB, Replication, Bypass RLS | {} replica | Replication | {} (编辑:焦作站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |