What are SQL comments?

Forums SQLWhat are SQL comments?
Staff asked 2 months ago

Answers (2)

Add Answer
Umang Ramani Marked As Accepted
Staff answered 2 months ago

There are three types of comments, which are given below:

  • Single line comments.
  • Multi-line comments
  • Inline comments

Single Line Comment

-- single-line comment


Multi-line Comments

/* multi-line comment  
another comment */  
SELECT * FROM Customers;


Inline comments:

Multi line comment ->  
/* SELECT * FROM Teachers;  
SELECT * FROM Orders; */  



Staff answered 2 months ago

Comments in SQL queries are viewable by programmers and serve as explanations or annotations. It’s used to help humans understand SQL statements. It will be disregarded during SQL code parsing. Comments can be written on a single line or spread out over multiple lines.

It begins with two consecutive hyphens on a single line (—).
It starts with / and finishes with / for multi-line comments.


Select Categories