Examples of SQL Comments

These examples illustrate different ways to use the SQL comment indicators.

The following examples use each style of comment indicator, including the double hyphen ( -- ), braces ( { } ), and C-style ( /* . . . */ ) comment delimiters to include a comment after an SQL statement. The comment appears on the same line as the statement.
SELECT * FROM customer; -- Selects all columns and rows

SELECT * FROM customer; {Selects all columns and rows}

SELECT * FROM customer; /*Selects all columns and rows*/
The next three examples use the same SQL statement and the same comments as in the preceding examples, but place the comment on a separate line:
SELECT * FROM customer; 
   -- Selects all columns and rows

SELECT * FROM customer; 
   {Selects all columns and rows}

SELECT * FROM customer; 
   /*Selects all columns and rows*/
In the following examples, the user enters the same SQL statement as in the preceding example but now a multiple-line comment (or for the double-hyphen indicator, two comments) follows each statement:
SELECT * FROM customer;
   -- Selects all columns and rows
   -- from the customer table

SELECT * FROM customer;
   {Selects all columns and rows
    from the customer table}

SELECT * FROM customer;
   /*Selects all columns and rows
    from the customer table*/
Comments in any of these styles can also appear within an SQL statement:
SELECT *           -- Selects all columns and rows
   FROM customer;  -- from the customer table

SELECT *           {Selects all columns and rows}
   FROM customer;  {from the customer table}

SELECT *           /*Selects all columns and rows*/
   FROM customer;  /*from the customer table*/
If you use braces or C-style comments that are delimited by paired opening and closing indicators, the closing comment indicator must be in the same style as the opening comment indicator.