TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

DB2 - SQL Comments


What is the use of Comments?

Comments are used to explain sections of SQL statements, or to prevent execution of SQL statements.


How to add comments in SQL code?

The are two ways to comment a line.

  1. Single Line Comments

  2. Multi-line Comments


Let us see each type below:

Single Line Comments:

Single line comments start with --.

Any text between -- and the end of the line will be ignored (will not be executed).

Example 1:

--Select all column:
SELECT * FROM Employee;


Example 2:

You can also use single line comment like below.

SELECT * FROM Employee;   --Select all column:


Multi-line Comments:

Multi-line comments start with /* and end with */. Any text between /* and */ will be ignored.

Example 2:

/*Select all columns
in the Employee table:*/
SELECT * FROM Employee;

You can also use multi line comment like below.

SELECT Employeename, /*Age,*/ City FROM Employee;


If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal