SQL postgres 不断给出“模式不存在”的错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44063772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 05:13:46  来源:igfitidea点击:

postgres constantly gives "schema does not exist" errors

sqlpostgresql

提问by aaa90210

I managed to create a table in a schema FOO.

我设法在架构 FOO 中创建了一个表。

Whenever I then try and do anything, like even a basic select, I just get:

每当我尝试做任何事情时,甚至是基本的选择,我都会得到:

ERROR: schema "FOO" does not exist
SQL state: 3F000
Character: 15

I am running the select in the same edit window as I created (using pgAdmin4). I get the same error when I try and create a view call FOO.Info. Yet when I try and create a new table in FOO it works.

我在创建的同一编辑窗口中运行选择(使用 pgAdmin4)。当我尝试创建一个视图调用 FOO.Info 时,我遇到了同样的错误。然而,当我尝试在 FOO 中创建一个新表时,它可以工作。

What's going on? I am using the same syntax to refer to the table in the select as the create.

这是怎么回事?我使用相同的语法将 select 中的表作为 create 引用。

# worked fine
CREATE TABLE "FOO"."Events"
(
...

# all these have the error
select * from "FOO"."Events";
select * from FOO.Events;
select * from Foo.Events;
postgres=# \dn
  List of schemas
  Name  |  Owner   
--------+----------
 foo    | postgres
 public | postgres
(2 rows)

回答by Vao Tsun

I believe you created it as

我相信你创造了它

create schema FOO;

which creates schema "foo", not "FOO"

创建模式“foo”,而不是“FOO”

And then you reference it as

然后你将它引用为

select * from "FOO".table_name

so it is not found

所以没有找到