How to Add Comments in SQL?

Amansingh Javatpoint
1 min readMay 27, 2021

Comments are text notes that are incorporated into the program to make the code easier to understand. In SQL, commenting is used to explain various sections and to provide appropriate documentation to a program. In addition, it also prevents the code from being executed.

Comments can be added in SQL in the following ways:

  1. Single Line Comment
  2. Multi Line Comment
  3. Inline Comment

1. Single Line Comments: Comments which are added to a single line are called as single line comments.

Syntax:

— Add a single line which is to be commented

Example:

SELECT * FROM employee; — Display all the records from employee table

Output:

+ — — — — + — — — — — + — — — — — — +

| Emp_ID | Emp_Name | Emp_Salary |

+ — — — — + — — — — — + — — — — — — +

| 1 | Nikita | 30000 |

| 2 | Riddhi | 25000 |

| 3 | Nayan | 45000 |

| 4 | Shruti | 15000 |

| 5 | Anurati | 55000 |

+ — — — — + — — — — — + — — — — — — +

5 rows in set (0.00 sec)

--

--