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:
- Single-line comments
- Multi-line comments
- 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: