Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Postgres performance optimization and best practices guide maintained by Supabase
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/schema-lowercase-identifiers.md
1---2title: Use Lowercase Identifiers for Compatibility3impact: MEDIUM4impactDescription: Avoid case-sensitivity bugs with tools, ORMs, and AI assistants5tags: naming, identifiers, case-sensitivity, schema, conventions6---78## Use Lowercase Identifiers for Compatibility910PostgreSQL folds unquoted identifiers to lowercase. Quoted mixed-case identifiers require quotes forever and cause issues with tools, ORMs, and AI assistants that may not recognize them.1112**Incorrect (mixed-case identifiers):**1314```sql15-- Quoted identifiers preserve case but require quotes everywhere16CREATE TABLE "Users" (17"userId" bigint PRIMARY KEY,18"firstName" text,19"lastName" text20);2122-- Must always quote or queries fail23SELECT "firstName" FROM "Users" WHERE "userId" = 1;2425-- This fails - Users becomes users without quotes26SELECT firstName FROM Users;27-- ERROR: relation "users" does not exist28```2930**Correct (lowercase snake_case):**3132```sql33-- Unquoted lowercase identifiers are portable and tool-friendly34CREATE TABLE users (35user_id bigint PRIMARY KEY,36first_name text,37last_name text38);3940-- Works without quotes, recognized by all tools41SELECT first_name FROM users WHERE user_id = 1;42```4344Common sources of mixed-case identifiers:4546```sql47-- ORMs often generate quoted camelCase - configure them to use snake_case48-- Migrations from other databases may preserve original casing49-- Some GUI tools quote identifiers by default - disable this5051-- If stuck with mixed-case, create views as a compatibility layer52CREATE VIEW users AS SELECT "userId" AS user_id, "firstName" AS first_name FROM "Users";53```5455Reference: [Identifiers and Key Words](https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS)56