Comment in SQL and PL-SQL

comments

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
dbgeek.in

Sharing is caring!

You May Also Like..

IN

Oracle – IN Condition

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

NULLIF

Oracle SQL_Null Related functions-3_NULLIF

Hi Aliens, Today, we will talk about another Null Related Function, NULLIF. You can read my notes on NVL, NVL2 […]

WHERE

SQL – WHERE clause

Hi DBgeek Army, Welcome back to the world of Oracle! Where clause helps to select desired rows or helps to […]

Leave a Reply

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