如何让 PostgreSQL / pgAdmin 在区分大小写方面表现得更好一些?
我在pgAdmin中设计了一组表。我给出的名称包括 Products
和 ProductRID
。但当我去查询这个表时却发现这样的查询产生了未知的关系,我感到非常惊讶:
select * from Products
显然访问这个表的正确方法是
select * from "Products"
非常丑陋的。我可以将表重命名为全部小写,以便在不带引号的情况下进行查询,但它看起来很难看。是否有任何类型的设置可以保留大小写,但行为时不区分大小写?
I designed a set of tables in pgAdmin. I gave names like Products
and ProductRID
. I was very surprised though when I went to query this table only to find a query like this yielded unknown relation:
select * from Products
Apparently the proper way to access this is
select * from "Products"
which is very ugly. I can rename the tables to all lower case to query without quotes, but then it looks ugly. Is there any kind of a setting so that it will retain the case, but behave without case sensitivity?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,没有魔法设置。处理区分大小写的最佳方法是在创建关系时不要引用它们。如果您处于模式设计的早期阶段,请继续将它们(和列名称)重命名为小写。 “看起来丑陋”的问题将会消失,因为在您的查询中您仍然可以这样做
并且它会正常工作。
No there is no magic setting. The best way to deal with case sensitivity is to not quote your relations when you are creating them. If you are early on in schema design, go ahead and rename them (and column names) to lower case. The "looks ugly" problem will go away because in your queries you can still do
and it will work fine.
您可以查看相关wiki以获得准确的答案
为什么我的表和列名称是在我的查询中无法识别?为什么不保留大写?
希望它能澄清。
You may check the relative wiki to get the precise answer
Why are my table and column names not recognized in my query? Why is capitalization not preserved?
Hope it clarifies.