PL/SQL provides comments to make code more readable and understandable. Comments are non-executable statements ignored by the compiler during execution.
- Improve code readability and understanding.
- Help explain complex queries and logic.
- They are ignored during program execution.
- Provide context and documentation for database code.
Types of PL/SQL Comments
Comments in PL/SQL are explanatory statements used to improve the readability and understanding of the code. It supports two main types of comments.

1. Single-Line Comments
A single-line comment in PL/SQL starts with --. Everything written after it on the same line is treated as a comment and ignored by the compiler. It is used for short explanations or notes in the code.
Syntax
-- This is a single line commentExample: PL/SQL Program to illustrate Single-Line Comment
DECLARE
a NUMBER := 10; -- First number
b NUMBER := 20; -- Second number
c NUMBER; -- Variable to store sum
BEGIN
c := a + b; -- Adding two numbers
DBMS_OUTPUT.PUT_LINE(c); -- Display result
END;
/2. Multi-Line Comments
Multi-line comments in PL/SQL are used to comment multiple lines together. They start with /* and end with */. They are useful for writing detailed explanations in the code.
Syntax
/* Multi line comment starts
. . . continue . . .
. . . continue . . .
. . . continue . . .
Multi line comment ends */Example: PL/SQL Program to illustrate the Multi-Line Comment
DECLARE
a NUMBER := 10;
b NUMBER := 20;
c NUMBER;
BEGIN
/* Adding the values
of a and b */
c := a + b;
DBMS_OUTPUT.PUT_LINE(c);
END;
/Importance of Comments in PL/SQL
- Comments make the code more readable and easier to understand for programmers.
- They help during debugging by explaining the logic and flow of the program.
- Comments are useful for documenting variables, functions and important statements in the code.
- They can be used to mark future changes or improvements needed in the program.
- Comments help other developers understand and maintain the code more easily.