Annotate SQL code with single-line (--) or block (/* */) comments. All major SQL engines support both styles.

Inline comments (--) and block comments (/* */) document SQL code for readability and maintenance. Comments are stripped during parsing and have no runtime effect. Use them to explain non-obvious business logic, document assumptions, and mark TODOs in complex queries.

Compatibility

Show:
Database System Support Status Since Version Notes
MySQL ✓ Supported all Both -- and /* */ supported. Special /*! version */ conditional execution syntax executes the enclosed SQL only on MySQL servers at or above the given version number.
PostgreSQL ✓ Supported all Both -- and /* */ supported. Block comments can be nested: /* outer /* inner */ still commented */.
SQL Server ✓ Supported all Both -- and /* */ supported. No nested block comments.
Oracle ✓ Supported all Both -- and /* */ supported. Optimizer hints use the /*+ hint */ form.
SQLite ✓ Supported all Both -- and /* */ supported. No nested block comments.

Details

Single-line comments (--) and block comments (/* */) are universally supported. Notable differences: PostgreSQL allows nested block comments; MySQL supports conditional execution via /*!version ... */; Oracle uses /*+ ... */ for query optimizer hints.

Standard Syntax

-- single-line comment /* block comment spans multiple lines */ SELECT col -- inline comment FROM tbl;

Version Support

MySQL: Since all PostgreSQL: Since all SQL Server: Since all Oracle: Since all SQLite: Since all

Per-Database Syntax & Notes

MySQL

Both -- and /* */ supported. Special /*! version */ conditional execution syntax executes the enclosed SQL only on MySQL servers at or above the given version number.

-- single-line /* block */ /*!50700 SELECT 'MySQL 5.7+'; */

PostgreSQL

Both -- and /* */ supported. Block comments can be nested: /* outer /* inner */ still commented */.

-- single-line /* block */ /* outer /* nested */ still a comment */

SQL Server

Both -- and /* */ supported. No nested block comments.

-- single-line /* block */

Oracle

Both -- and /* */ supported. Optimizer hints use the /*+ hint */ form.

-- single-line /* block */ SELECT /*+ FULL(t) */ * FROM t;

SQLite

Both -- and /* */ supported. No nested block comments.

-- single-line /* block */