简体   繁体   English

"在 PostgreSQL 上执行查询的表名周围是否必须使用“”?"

[英]Is it mandatory to use "" around the table name performing query on PostgreSQL?

I am not so into PostgreSQL<\/strong> and pgAdmin 4<\/strong> and I have the following doubt.我不太喜欢PostgreSQL<\/strong>和pgAdmin 4<\/strong> ,我有以下疑问。

Following a screenshot of what I can see in my pgAdmin4:按照我在 pgAdmin4 中看到的屏幕截图:

在此处输入图像描述<\/a>

As you can see it is performing this very simple query:如您所见,它正在执行这个非常简单的查询:

SELECT * FROM public."Example"
ORDER BY id ASC 

The thing that I am not understanding is what is this public name in front of the Example table name.我不明白的是 Example 表名前面的这个公共名称是什么。 What is it?它是什么?

As said in postgres documentation: "By default tables (and other objects) are automatically put into a schema named "public". Every new database contains such a schema."正如 postgres 文档中所说: “默认情况下,表(和其他对象)会自动放入名为“public”的模式中。每个新数据库都包含这样的模式。”

So it means that in PosgreSQL database the "" around the table name are mandatory?所以这意味着在 PosgreSQL 数据库中,表名周围的“”是强制性的?

Not really but you need to use it if you are using reserved keywords (such as "user","name"and other)or if your table's name contains uppercase(it's your case) letters.不是真的,但如果您使用保留关键字(例如“user”、“name”和其他)或者如果您的表的名称包含大写(这是您的大小写)字母,则需要使用它。 Anyways, in this case if you can it's better change your table's name.无论如何,在这种情况下,如果可以的话,最好更改表的名称。

您应该将表名更改为小写字母,然后再试一次

select * from example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM