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

Filter by Database
SQL COMMENTS Compatibility Across Databases
Database System Support Status Since Version Notes
MySQL Native 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 Native all Both -- and /* */ supported. Block comments can be nested: /* outer /* inner */ still commented */.
SQL Server Native all Both -- and /* */ supported. No nested block comments.
Oracle Native all Both -- and /* */ supported. Optimizer hints use the /*+ hint */ form.
SQLite Native 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: Native in all listed versions PostgreSQL: Native in all listed versions SQL Server: Native in all listed versions Oracle: Native in all listed versions SQLite: Native in all listed versions

Per-Database Syntax & Notes

MySQL Native syntax

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 Native syntax

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

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

SQL Server Native syntax

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

-- single-line /* block */

Oracle Native syntax

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

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

SQLite Native syntax

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

-- single-line /* block */