如何让 PostgreSQL / pgAdmin 在区分大小写方面表现得更好一些?

发布于 2024-09-18 21:10:55 字数 321 浏览 5 评论 0原文

我在pgAdmin中设计了一组表。我给出的名称包括 ProductsProductRID。但当我去查询这个表时却发现这样的查询产生了未知的关系,我感到非常惊讶:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久光 2024-09-25 21:10:55

不,没有魔法设置。处理区分大小写的最佳方法是在创建关系时不要引用它们。如果您处于模式设计的早期阶段,请继续将它们(和列名称)重命名为小写。 “看起来丑陋”的问题将会消失,因为在您的查询中您仍然可以这样做

SELECT * FROM Products

并且它会正常工作。

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

SELECT * FROM Products

and it will work fine.

谎言月老 2024-09-25 21:10:55

您可以查看相关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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文