4 ms·
Postgres has very counterintuitive behaviour around case-sensitivity. CREATE TABLE CamelCase(...) SELECT * FROM "CamelCase"; will fail with "CamelCase" no
by yen223 2y ago
Postgres has very counterintuitive behaviour around case-sensitivity.
CREATE TABLE CamelCase(...)
SELECT * FROM "CamelCase";
will fail with "CamelCase" not being a table.
That's because the CREATE TABLE statement creates a table named "camelcase", not "CamelCase", despite what you might assume from the query.
- hu3 2y agoDaily WTF. No bit seriously, thanks for sharing. I'll always do lower case table names from now on.
- DrBenCarson 2y agoIt’s not lower case, you should be using snake_case
- hu3 2y agoyeah. both
- sixbrx 2y agoThats not particular to postgres, that's the same in Oracle (or any other db following ISO case handling I believe), just with true (quoted) table name being all uppercase instead for the latter but with same error. You can quote the table name in the create statement to get the camelcase table name. Just remember to quote in both creation and usage or neither, is a good rule of thumb