Reference
SQL Syntax Reference
A concise reference for SQL lexical structure: strings, identifiers, comments and dialect differences.
A SQL statement is a sequence of tokens: keywords, identifiers, string literals, numbers, operators and punctuation. Whitespace and comments separate tokens and otherwise carry no meaning.
01The rules that matter
- Single quotes delimit string literals; a literal quote is doubled (or backslash-escaped in MySQL).
- Double quotes, backticks (MySQL) or square brackets (T-SQL) delimit identifiers.
- -- starts a line comment everywhere; /* */ is a block comment; MySQL also accepts #.
- PostgreSQL adds dollar-quoted strings ($tag$ … $tag$) so a literal can contain anything, including quotes.
02Why dialect matters
The same characters mean different things across engines, so a validator that assumes one dialect will misread another. Selecting the dialect keeps tokenising and structural checks accurate.
Limitations
This reference covers lexical structure only; it says nothing about query semantics, your schema or performance.
Frequently asked questions
- Is a backtick always an identifier?
- Only in MySQL; PostgreSQL and the standard use double quotes, and T-SQL uses square brackets.
- Can a string contain a semicolon?
- Yes. A semicolon inside a string literal never ends a statement; only a top-level semicolon does.
Sources
- ISO/IEC 9075-1:2023 — Information technology, Database languages SQL — ISO/IEC (accessed 2026-10-10)
Test this in your browser
The tool runs entirely in your browser; the input you use never leaves it.
About the author
Gampangin builds and maintains free, browser-based developer tools and the documentation that makes them trustworthy. The organization is accountable for every page published on this site.