问题
After renaming a table in Postgres I'm experiencing a strange behaviour: if I reference the table without the quotes it doesn't work.
For example: the original name was «devices», after I've altered it to «Devices» the following SELECT breaks:
SELECT * from Devices
but this one
SELECT * from "Devices"
works as expected.
Any idea?
回答1:
Per the manual, identifiers are lower-cased unless quoted.
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.
To PostgreSQL all these are names for the devices
table:
devices
DEVICES
Devices
DeViCES
but these are names for separate tables with mixed-case names:
"Devices"
"DEVICES"
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.
回答2:
Rename it again to devices
(lower case without double quotes). Then you it will be possible to refer to it in any case you want including mixed case:
select * from dEvIceS
来源:https://stackoverflow.com/questions/17746491/after-renameing-a-table-im-forced-to-use-quoted-identifiers