Quoted Identifiers Keep Case
Unquoted identifiers fold to lowercase while quoted identifiers keep their exact spelling, so mixed-case quoted names need quoting in every later reference.
Code
-- 未加引号:标识符一律折叠成小写,两种写法是同一张表
CREATE TABLE sessions (id integer);
CREATE TABLE SESSIONS (note text);
DROP TABLE IF EXISTS sessions; -- 两行 DDL 互相踩同名表
-- 加双引号:大小写与拼写原样保留,产生的是另一张表
CREATE TABLE "Sessions" (id integer);
INSERT INTO "Sessions" VALUES (1);
-- 之后每次引用都必须带引号,漏了引号会找错对象
SELECT * FROM "Sessions"; -- 正常
-- SELECT * FROM Sessions; -- 解析成 sessions:ERROR: relation "sessions" does not exist
-- 引号还能解锁保留字与特殊字符作标识符
CREATE TABLE "select order" (id integer);
SELECT column_name, table_name
FROM information_schema.columns
WHERE table_name IN ('Sessions', 'select order');
-- 清理演示对象
DROP TABLE "Sessions";
DROP TABLE "select order";
DROP TABLE IF EXISTS sessions;What the code does
Several statements share this file — SELECT / INSERT / CREATE, with information_schema.columns among the objects involved.
Concretely, the SQL combines: a WHERE clause narrowing which rows one statement affects.
Using it
Run the statement against the information_schema.columns table.
Key statements
SELECT column_name, table_name
FROM information_schema.columns
WHERE table_name IN ('Sessions', 'select order');
SELECT * FROM "Sessions"; -- 正常
CREATE TABLE "select order" (id integer);
DROP TABLE IF EXISTS sessions; -- 两行 DDL 互相踩同名表
CREATE TABLE "Sessions" (id integer);
Interactive Tools for This Topic
SQL DDL to TypeScript ConverterConvert SQL CREATE TABLE DDL statements into strict TypeScript interfaces with nullable, array, enum, JSONB, and Date or ISO string column mappings.PostgreSQL EXPLAIN AnalyzerAnalyze PostgreSQL EXPLAIN ANALYZE text or FORMAT JSON plans locally to flag Seq Scans, slow nodes, row misestimates, disk sorts, and index hints.Case ConverterConvert text between lowercase, uppercase, title, sentence, camelCase, snake_case, and kebab-case while preserving Unicode letters and numbers.Dotenv File ParserParse .env file content into a JSON object, handling comments, export prefixes, single quotes, and double-quoted escape sequences.
FAQ
- Which tables does this file reference?
- `information_schema.columns`.
Report a problem with this exampleOpens a pre-filled issue on GitHub.