# Single vs double quotes in SQL

Source: https://sqlstreak.com/sql/single-vs-double-quotes · Tested on PostgreSQL 18.6 and SQLite 3.54.1; results generated 2026-11-22.


**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 |

## Examples

### Text in single quotes works everywhere

```sql
SELECT name
FROM pets
WHERE species = 'cat'
ORDER BY name;
```

Result (both engines):

| name |
| --- |
| Luna |
| Mochi |
| Olive |
| Pepper |
| Pumpkin |
| Socks |
| Tofu |

### 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.

```sql
SELECT name
FROM pets
WHERE species = "cat"
ORDER BY name;
```

PostgreSQL: error: column "cat" does not exist

SQLite:

| name |
| --- |
| Luna |
| Mochi |
| Olive |
| Pepper |
| Pumpkin |
| Socks |
| Tofu |

### Double quotes for a name with a space

```sql
SELECT name AS "Pet name", age AS "Age in years"
FROM pets
ORDER BY age DESC
LIMIT 3;
```

Result (both engines):

| Pet name | Age in years |
| --- | --- |
| Tofu | 11 |
| Gizmo | 10 |
| Bruno | 9 |

### An apostrophe inside text

```sql
SELECT 'Rocket''s menu' AS label, COUNT(*) AS items
FROM menu_items;
```

Result (both engines):

| label | items |
| --- | --- |
| Rocket's menu | 11 |

## 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.
