I won't say much nonsense, let's just read the code~
SELECT sum(aa) as "recordNumber" FROM table SELECT sum(aa) as recordNumber FROM table
The postgis query field converts the field field to lowercase. If uppercase characters are required, double quotes are required.
Supplement: Table name, column name, user name case issues in Postgresql
Note: It is double quotes, single quotes may be parsed into ordinary characters, so it is an unrecognized field.
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)
> As can be seen from the above, if double quotes are not added, the table names will be converted to lowercase. If you want to mix upper and lower case, you need to add double quotes.
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 "" 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 | {}
Experiments have shown that fields will be automatically converted to lowercase like users, unless double quotes are added. In fact, the best way is to use lowercase all, so as to minimize the occurrence of problems.
The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.