The SQL Comments are primarily used to explain the various sections of an SQL statement. These help in the prevention of various statements in SQL. Comments matter a lot in various programming languages. Remember that a Microsoft Access DB (database) doesn’t support the comments. Thus, Microsoft Edge and Mozilla Firefox make use of the Microsoft Access database to make it work.
In this article, we will dive deeper into the COMMENTS in SQL according to the GATE Syllabus for (Computer Science Engineering) CSE. Keep reading ahead to learn more.
Table of Contents
What are COMMENTS in SQL?
In any programming language, comments always matter a lot. Similarly, it matters in SQL too. We will learn more about how to write comments in an SQL snippet in this set.
The comments could be written in three formats:
- Single line
- In line
- Multi line
Single line comments
Those comments that start and end in just a single line are termed as single line comments. In this case, the line that starts with ‘–‘ would be a comment. It would not be executed at all.
Syntax
Here is how the syntax of the single line comments goes:
— single line comment
— some other comment
SELECT * FROM Consumers;
Multi line comments
Those comments that start in one line and then end in different lines are termed as the multi-line comments. In this case, the line that starts with ‘/*’ will be considered as the starting point of the comment, while it will terminate when ‘*/’ is encountered.
Syntax
Here is how the syntax of the multi line comments goes:
/* multi line comment
some other comment */
SELECT * FROM Consumers;
In line comments
The in-line comments are basically an extension of the multi-line comments. These comments could be stated between the statements. These are enclosed between the ‘/*’ and the ‘*/’ symbols.
Syntax
Here is how the syntax of the in line comments goes:
SELECT * FROM /* Consumers; */
More Examples
Multi line comment ->
/* SELECT * FROM Employees;
SELECT * FROM EMPLOYEE_DETAILS;
SELECT * FROM Clients; */
SELECT * FROM Projects;
In line comment ->
SELECT * FROM Employees;
SELECT * FROM /* EMPLOYEE_DETAILS;
SELECT * FROM Clients;
SELECT * FROM */ Projects;
Keep learning and stay tuned to get the latest updates on the GATE Exam along with Eligibility Criteria, GATE Syllabus for CSE (Computer Science Engineering), GATE CSE Notes, GATE CSE Question Paper, and more.
Also Explore,
Comments