SQL compared
Single vs double quotes in SQL
Updated · Tested on PostgreSQL 18.6 and SQLite 3.54.1 (results generated , re-checked on every release)
Short answer
Single quotes make text: 'cat'. Double quotes name a column or table: "pets", needed only for names with spaces, capitals or reserved words. PostgreSQL enforces the difference; SQLite quietly treats an unknown double-quoted name as text, which hides the bug.
Side by side
| 'single quotes' | "double quotes" | |
|---|---|---|
| Means | A text value | A name (column, table, alias) |
| Example | WHERE species = 'cat' | SELECT name AS "Pet name" |
| An apostrophe inside | Write it twice: 'Rocket''s' | Not an issue |
| Wrong use | 'name' is just the text name | "cat" is a column called cat |
The same data, each way
Every query below was run on PostgreSQL and SQLite when this page was built; the tables are what came back.
Text in single quotes works everywhere
SELECT name
FROM pets
WHERE species = 'cat'
ORDER BY name;Result (PostgreSQL and SQLite, identical): 7 rows
| name |
|---|
| Luna |
| Mochi |
| Olive |
| Pepper |
| Pumpkin |
| Socks |
| Tofu |
Try it: PostgreSQL playground · SQLite playground
Text in double quotes
PostgreSQL looks for a column called cat. SQLite finds no such column and falls back to the text 'cat', so it seems to work.
SELECT name
FROM pets
WHERE species = "cat"
ORDER BY name;PostgreSQLERROR: column "cat" does not exist
SQLite: 7 rows
| name |
|---|
| Luna |
| Mochi |
| Olive |
| Pepper |
| Pumpkin |
| Socks |
| Tofu |
Try it: PostgreSQL playground · SQLite playground
Double quotes for a name with a space
SELECT name AS "Pet name", age AS "Age in years"
FROM pets
ORDER BY age DESC
LIMIT 3;Result (PostgreSQL and SQLite, identical): 3 rows
| Pet name | Age in years |
|---|---|
| Tofu | 11 |
| Gizmo | 10 |
| Bruno | 9 |
Try it: PostgreSQL playground · SQLite playground
An apostrophe inside text
SELECT 'Rocket''s menu' AS label, COUNT(*) AS items
FROM menu_items;Result (PostgreSQL and SQLite, identical): 1 row
| label | items |
|---|---|
| Rocket's menu | 11 |
Try it: PostgreSQL playground · SQLite playground
When to use which
- 'single quotes'
Every text and date value:
'cat','2026-03-15','Rocket''s'.- "double quotes"
Only for names that need them: spaces, capitals you want to keep, reserved words. Plain lowercase names need none.
Common mistakes
Double quotes around text, a habit from JavaScript or Python: PostgreSQL reports
column "…" does not exist.Single quotes around a column name in ORDER BY (
ORDER BY 'price'): that sorts by a constant, so nothing is sorted.Creating a column as
"Name": from then on you must always write"Name"with the capital and the quotes.
PostgreSQL and SQLite
PostgreSQL follows the standard strictly. SQLite accepts a double-quoted string when no column of that name exists (a legacy fallback the SQLite authors call a misfeature), which is why the second example runs there.
Official documentation
Go deeper
- Guide: SQL WHERE clause: filtering rows
- Practice: SQL WHERE practice: 9 exercises with answers
- Lesson: Filter with WHERE (free)
Make it stick in five minutes a day
“Filter with WHERE” teaches this step by step on a real database, with instant feedback. Free, no account needed.