// strings reference

SQL identifier quoting

Identifiers need different delimiters than string literals, and each engine's case-folding rules turn quoting into a portability question of its own.

Catégorie
Strings
Returns
identifier
In this category
79 of 172

Syntaxe

"name"
`name`
[name]

Each block is a separate form. The support table and the examples show which engine takes which.

Prise en charge des moteurs

MoteurSupportNotes
SQL Server Oui Supported under this name.
PostgreSQL Oui Supported under this name.
MySQL Oui Supported under this name.
SQLite Oui Supported under this name.
Oracle Oui Supported under this name.

Exemples

PostgreSQL

SELECT "select" FROM "Users";  -- quoted identifiers keep case

MySQL

SELECT `order` FROM `order details`;  -- backticks for reserved words

SQL Server

SELECT [order] FROM [Order Details];

Bon à savoir

  • The standard delimiter is double quotes; SQL Server accepts [brackets] (and quotes under QUOTED_IDENTIFIER); MySQL uses backticks by default and quotes only with ANSI_QUOTES.
  • Case folding bites: PostgreSQL lowercases unquoted identifiers and preserves quoted ones, so users and "Users" are different tables. Oracle uppercases unquoted names.
  • MySQL's "double quotes" are string literals unless ANSI_QUOTES is set, the reverse of the standard, a classic cross-engine bug.
  • Reserved words and spaces always need quoting: order, group, select are legal column names everywhere once delimited.

Questions about Quoting identifiers

Are double quotes a string or an identifier?

An identifier in the SQL standard, PostgreSQL, Oracle, SQL Server (QUOTED_IDENTIFIER ON, the driver default) and MySQL with ANSI_QUOTES. Default MySQL treats them as strings. SQLite treats them as identifiers but falls back to a string when no such column exists.

Why does my quoted table name stop resolving?

Quoting preserves case: "Users" is not users on PostgreSQL. Drop the quotes to get case-folding, or match the exact stored case.

How do I quote identifiers safely in dynamic SQL?

SQL Server's QUOTENAME doubles embedded closers; PostgreSQL's quote_ident() does the same job, and MySQL's sys.quote_identifier() wraps in backticks. Validating names against the catalog or an allowlist is still the safer first step.

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, SQLite, Oracle.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.