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.
| 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. |
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.
Both -- and /* */ supported. Special /*! version */ conditional execution syntax executes the enclosed SQL only on MySQL servers at or above the given version number.
Both -- and /* */ supported. Block comments can be nested: /* outer /* inner */ still commented */.
Both -- and /* */ supported. No nested block comments.
Both -- and /* */ supported. Optimizer hints use the /*+ hint */ form.
Both -- and /* */ supported. No nested block comments.