怎么在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 | {}
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 | {}關于怎么在postgresql中將查詢結果為大寫的名稱轉換為小寫問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。