博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Postgresql中表名、列名、用户名大小写问题
阅读量:2432 次
发布时间:2019-05-10

本文共 2991 字,大约阅读时间需要 9 分钟。

原文: https://blog.csdn.net/pg_hgdb/article/details/79227237

注意:是双引号,单引号可能会被解析成普通字符,因而是不识别的字段

highgo=# create table "ExChange" (id int);CREATE TABLEhighgo=# create table ExChange (id int);CREATE TABLEhighgo=# \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 1highgo=# insert into "ExChange" values (2);INSERT 0 1highgo=# 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 1highgo=# 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 oncehighgo=# create table exchange (ID int,name text);CREATE TABLEhighgo=# 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 existLINE 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 existshighgo=# create user "AAA";CREATE ROLEhighgo=# \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                                                | {}

实验证明,字段与用户同样会被自动转化为小写,除非添加双引号。 其实最好的办法就是全部用小写,这样才能尽量减少问题的出现。

你可能感兴趣的文章
Jsp连接数据库大全
查看>>
WebSphere Application Server 常见问题及解答:安全
查看>>
WebSphere Application Server 常见问题及解答:集群
查看>>
使用 SIBus JMS 提供者
查看>>
调试 SCA 调用
查看>>
SOA 治理框架和解决方案架构
查看>>
面向企业的云计算—了解云的一些基本概念
查看>>
实现基于角色的授权
查看>>
使用定制工作流程更新 RSS 数据源
查看>>
使用 WebSphere Business Modeler 进行业务建模
查看>>
SOA 案例研究:Web 2.0 SOA 场景
查看>>
IBM BPM BlueWorks:一次 WebSphere 云试验
查看>>
websphere笔记
查看>>
使用 WebSphere Process Server 关系开发集成解决方案(2)
查看>>
最新最全的Portlet 通信过程详解
查看>>
在LINUX中安装WEB SPHERE5.1的正确方法
查看>>
WebSphere简单故障排查
查看>>
ITCAM for Websphere v6.0与ITM v6.1集成的快速指南
查看>>
数据泵 TTS(传输表空间技术)
查看>>
weblogic管理2 - 创建并启动一个managed server
查看>>