SQL Comments with Example

Comments in SQL - Comments and Uncomment in SQL 

comment in SQL with example

Comment in SQL 
SQL comments are used to explain sections of SQL statements, or to prevent the execution of SQL statements.

Syntax of Comments 
The basic Syntax of the comment is given below

--Select all: 

Example of Comments
Basic example of comments is given below.

 --Select all: 
SELECT * FROM Customers;

Types of Comments 
There are two types of comments in SQL.
  • Single line Comments 
  • Multiline Comments 
  • Inline Comments

Single Line Comments 
In SQL single-line comments are used for Comments starting and ending in a single line are considered as single line comments. A single-line comment starting with ‘–-‘ is a comment and will not be executed.

Example of Single-line Comment

Consider the below example to understand the single-line comment. 

--Select all: 
SELECT * FROM Student;

Ignore the end of the line.

SELECT * FROM Student-- WHERE City='Gorakpur';

Ignore statement. 

--SELECT * FROM Student; 
SELECT * FROM College;

Multiline Comment 

How to comment a SQL Statements?
How to unComment a SQL Statement?

Hope!!! The above Tutorials on " Comments in SQL With Example "Are helpful for you...

QA acharya

Tags: Comments in SQL , SQL Comments with Example, Example of Comment in SQL 

Post a Comment