SQL Single Line Comments

SQL Single Line Comments contain a single line a comment. They start and end in a single line.

Single Line comments in SQL can be inserted using ‘–‘ before the line. 

Syntax:

Syntax to insert single line comment in SQL is:

— single line comment

SQL Single Line Comments Example

In this example, we use a single line comment to explain a query in SQL.

Query:

-- query to fetch customers records.
SELECT * FROM customers;

SQL Comments

SQL Comments explain sections of SQL statements or prevent SQL statements from being executed.

There are 3 types of comments in SQL:

  1. Single-line comments
  2. Multi-line comments
  3. In-line comments

These are the three commenting methods in SQL, each with its unique use. Let’s discuss these SQL comments in detail below:

Similar Reads

SQL Single Line Comments

SQL Single Line Comments contain a single line a comment. They start and end in a single line....

SQL Multi-Line Comments

SQL Multi-line comments contain multiple lines in a single comment. They start from one line and ends in a different line....

SQL In-Line Comments

SQL In-line comments are an extension of multi-line comments, these comments are used in between of a SQL statement....

Important Points About SQL Comments

SQL comments are annotations in the code that are not executed by the SQL engine, serving as notes or explanations for human readers to understand the code better. There are 3 types of comments in SQL– Single Line comments, Multi-Line comments and In-line comments. Proper use of comments in SQL can make scripts easier to understand, maintain, and debug, facilitating quicker reviews and onboarding of new team members SQL comments are not supported in Microsoft Access databases. Some database, like Oracle, provide additional features for commenting, such as the COMMENT ON statement to attach explanatory text to database objects....