SQL - Syntax
Overview
SQL is composed of statements terminated by ;
(MySQL/SQLite). SQL Server allows batches terminated by GO
in tools, though ;
is recommended for statement termination.
Comments
-- single line
/* block comment */
-- single line
/* block comment */
-- single line
/* block comment */
Identifiers
- MySQL: backticks
`name`
(or ANSI quotes ifANSI_QUOTES
mode enabled). - SQL Server: square brackets
[name]
or double quotes with QUOTED_IDENTIFIER ON. - SQLite: double quotes
"name"
(also supports backticks).
Example Statement
SELECT 1 + 2 AS sum; -- 3
SELECT 1 + 2 AS sum; -- 3
SELECT 1 + 2 AS sum; -- 3
Live Output
sum |
---|
3 |