SQL - Comments

Overview

Comments document intent and disable code. Use -- for single-line, /* ... */ for block comments.

-- single line
/* block comment */
SELECT 1; -- trailing comment
-- single line
/* block comment */
SELECT 1; -- trailing comment
-- single line
/* block comment */
SELECT 1; -- trailing comment

Tips

  • Place comments on their own lines or after a statement.
  • Avoid nesting block comments.
  • Keep comments concise and maintain them as code evolves.