PostgreSQL:表名/模式混淆 [英] Postgresql: table name / schema confusion
问题描述
我在我的postgresql数据库的公共模式中创建了一个表 Abc
。根据文档, public
应该是默认模式。 search_path
设置为 $ user,public
。但是以下操作失败:
从Abc
并且此调用也失败:
选择* from public.Abc
两者都会产生一个错误,指出关系...不存在
。但这可以正常工作:
从公共场所选择*。 Abc
我是一位经验丰富的T-SQL开发人员,但对postgresql还是陌生的。根据文档,应该可以在postgresql中使用普通 SQL。但这对我来说不起作用。任何提示我可能搞砸了吗??
Postgresql默认使用小写字符,同时对列/表名区分大小写:
从公共场所选择* Abc
实际上是:
select * from public.abc
这是因为您的表名为Abc,因此无法找到它。
您可以通过引号替换小写形式的行为,因此 Abc被视为Abc。
I created a table Abc
in the public schema of my postgresql database. According to the documentation public
should be the default schema. search_path
is set to "$user",public
as expected. But the following fails:
select * from Abc
and this call fails too:
select * from public.Abc
Both produce an error saying that relation ... does not exist
. But this one works fine:
select * from public."Abc"
I'm an experienced T-SQL developer, but new to postgresql. According to the documenation, it should be possible to use "normal" SQL with postgresql. But it does not work in my case. Any hint what I might have messed up!?
Postgresql defaults to lower case characters while being case sensitive with column/table names:
select * from public.Abc
is actually:
select * from public.abc
That's because your table is called Abc, so it cannot be found.
You can override this lower case behavior via quotation marks, so "Abc" is handled as Abc.
这篇关于PostgreSQL:表名/模式混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!