我就废话不多说了,大家还是直接看代码吧~
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 | {} highgo=# create table AAA; ERROR: 42601: syntax error at or near ";" LINE 1: create table AAA; ^ highgo=# create user AAA; ERROR: 42710: role "aaa" already exists highgo=# create user "AAA"; CREATE ROLE highgo=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- AAA | | {} aaa | | {} gpadmin | Superuser, Create role, Create DB | {} highgo | Superuser, Create role, Create DB, Replication, Bypass RLS | {} replica | Replication | {}
实验证明,字段与用户同样会被自动转化为小写,除非添加双引号。 其实最好的办法就是全部用小写,这样才能尽量减少问题的出现。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。如有错误或未考虑完全的地方,望不吝赐教。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“postgresql查询自动将大写的名称转换为小写的案例”评论...
更新动态
2024年11月27日
2024年11月27日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]