As is any programming languages comments matter a lot in SQL also. In this set we will learn about writing comments in any SQL snippet.
Comments can be written in the following three formats:
- Single line comments.
- Multi line comments
- In line comments
Single line comments: Comments starting and ending in a single line are considered as single line comments.
Line starting with ‘–‘ is a comment and will not be executed.
-- single line comment -- another comment SELECT * FROM Customers;
Multi line comments: Comments starting in one line and ending in different line are considered as multi line comments. Line starting with ‘/*’ is considered as starting point of comment and are terminated when ‘*/’ is encountered.
/* multi line comment another comment */ SELECT * FROM Customers;
In line comments: In line comments are an extension of multi line comments, comments can be stated in between the statements and are enclosed in between ‘/*’ and ‘*/’.
SELECT * FROM /* Customers; */
Multi line comment -> /* SELECT * FROM Students; SELECT * FROM STUDENT_DETAILS; SELECT * FROM Orders; */ SELECT * FROM Articles; In line comment -> SELECT * FROM Students; SELECT * FROM /* STUDENT_DETAILS; SELECT * FROM Orders; SELECT * FROM */ Articles;
This article is contributed by Pratik Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- Django project to create a Comments System
- SQL | Procedures in PL/SQL
- SQL | Difference between functions and stored procedures in PL/SQL
- Difference between T-SQL and PL-SQL
- Difference between SQL and T-SQL
- Mitigation of SQL Injection Attack using Prepared Statements (Parameterized Queries)
- SQL | SELECT Query
- SQL | Distinct Clause
- SQL | WHERE Clause
- SQL | AND and OR operators
- SQL | INSERT INTO Statement
- SQL | DELETE Statement
- SQL | UPDATE Statement
- SQL | SELECT TOP Clause
- SQL | ORDER BY
- SQL | Aliases
- SQL | Wildcard operators
- SQL | Union Clause
- SQL | CREATE
Improved By : Rajendrarajput