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
| 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
Version Support
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.
PostgreSQL Native syntax
Both -- and /* */ supported. Block comments can be nested: /* outer /* inner */ still commented */.
SQL Server Native syntax
Both -- and /* */ supported. No nested block comments.
Oracle Native syntax
Both -- and /* */ supported. Optimizer hints use the /*+ hint */ form.
SQLite Native syntax
Both -- and /* */ supported. No nested block comments.