Comments in SQL

Comments in SQL are used to include explanatory notes or documentation within SQL code, making it easier to understand. Comments are ignored by the SQL interpreter and do not affect the execution of the SQL statements.
There are two main types of comments in SQL: single-line comments and multi-line comments.

Single-Line Comments Single-line comments start with two hyphens (--). Everything after the -- on that line is considered a comment.

SQL Syntax

-- This is a single-line comment
SELECT * FROM employees; -- This comment follows an SQL statement

Multi-Line Comments Multi-line comments start with /* and end with */. They can span multiple lines.

SQL Syntax

/* This is a multi-line comment
which spans multiple lines */
SELECT * FROM employees;
/* This is another multi-line comment */
SELECT name, department FROM employees;