问题描述
在Postgres中重命名表格后,我遇到一种奇怪的行为:如果我引用不带引号的表格是行不通的。
After renaming a table in Postgres I'm experiencing a strange behaviour: if I reference the table without the quotes it doesn't work.
例如:原来的名称是«devices»,在将其更改为«Devices»之后,以下是SELECT中断:
For example: the original name was «devices», after I've altered it to «Devices» the following SELECT breaks:
c,因此名称混为一谈。现在,您必须在任何地方都使用加引号混合大小写来引用它。When you renamed it you did a RENAME TO "Devices", thus making the name mixed-case. You must now refer to it in quoted mixed case everywhere.
对于PostgreSQL,所有这些都是 devices 表的名称:
To PostgreSQL all these are names for the devices table:
- 设备
- 设备
- 设备
- DeViCES
- devices
- DEVICES
- Devices
- DeViCES
但这是带有混合大小写名称的单独表的名称:
but these are names for separate tables with mixed-case names:
- 设备
- 设备
- "Devices"
- "DEVICES"
这是根据SQL标准,但SQL要求实现大写未加引号的名称,其中PostgreSQL由于历史原因小写字母而使用。
This is according to the SQL standard except that SQL requires implementations to UPPER CASE un-quoted names, where PostgreSQL for historical reasons lower cases them instead.
这篇关于重命名表后,我被迫使用带引号的标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!