SQL COMMENTS are of 3 types
- Single Line Comments
- Multi Line Comments
- Inline Comments
Single Line Comments
The lines which starts with “–” in SQL are commented and not executed
Example-1:
SELECT *
FROM EMPLOYEES
–WHERE SALARY <5000;
Example-2:
–SELECT NAME
SELECT *
FROM EMPLOYEES;
Multi-line Comments
The lines start with “/*” and ends with “*/”
Example-1:
SELECT NAME, SALARY
FROM EMPLOYEES
/*WHERE NAME LIKE ‘%A’
AND SALARY < 5000;*/
Example-2:
SELECT NAME, SALARY
FROM EMPLOYEES
WHERE NAME =’RAJESH’
/*AND SALARY < 5000;*/
Inline Comments
These are used at the end of the line
Example-1:
SELECT * FROM /* EMPLOYEES; */
Example-2:
SELECT * FROM EMPLOYEES ; — This will print all rows in the table
Learn more : SQL Tutorial , SQL Interview Questions