adding comments to a sql statement



~1 min read


123 words

There are two ways to add a comment to a SQL query - using /* */ and --. The differences are as follows:

With a comment surrounded by /* and */, the comment can span multiple lines. That is not the case for the two-hyphen approach where each new line would require a repeat of the hyphens.

In both cases, however, there is no need for a space between the asterisk and the first/last character.


select * from my_table /*Select every field from my_table*/
  last_name = 'jones' /* for people with
                      the last name jones */
  and age > 30 -- where they are greater than 30 years of age
               --but not 30 years


Comments | Oracle

Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!