Comment in SQL and PL-SQL


admin DataBase, Oracle

Hi DBgeek Army,
Welcome back to the world of Oracle!
Comments are very important aspects of our code. No matter which programming language we are using, we must add comments to our code so that it helps us to read and maintain while working with the same code again in future.

Comments are nothing but general statements that do not play any role in the performance and functionality but describe the purpose of the blocks/statements within the application.
There are two types of comment in SQL.

  • Single-line comment
  • Single-line comments stats with double hyphen(–) and it covers only one line. If the comment is too long we will need to break the comment into multiple lines and each line must start with double hyphen (–) or go with second method Multi-Line comment.

  • Multi-Line comment
  • There are no restrictions with Multi-Line comment. Either we can use it with a single line or multiple lines. The whole comment must start with the combination of a Forward Slash and Asterisk (/*) and must end with the combination of Asterisk and Forward Slash (*/).

See the examples below.

You can add comments to your code as below.

It does not matter how you add your comment to the code but it should be clear and precise.

It is highly advisable to use comment methods as per their requirement. In General, Multi-Line comment method is used more frequently. Because in this method, the starting point and the ending point are in our hand. We can terminate comment at any point. See the below code.

We cannot do so with Single-Line comment method.
We can use these methods in SQL as well as PL-SQL using the same approaches.

If you have any questions/suggestions, please comment below or write me an email.
If you like this blog, do share with your friends and colleagues on your social media.
For more updates join my facebook group and do like my facebook page.

Thank you,
Kapil Kumar

Sharing is caring!

You May Also Like..


Parentheses in SQL

Hey time travellers, Though Parentheses are used pretty much everywhere in SQL but in this blog, we will talk about […]

Logical Conditions

Oracle – Logical Conditions

Hey time travellers, In this article, we will be discussing Logical Conditions. It is a very important aspect of SQL. […]


Oracle – IN Condition

Hey people, In this Oracle tutorial, we will learn how to use IN condition in SQL. IN condition is used […]

Leave a Reply

Your email address will not be published. Required fields are marked *