SQL Tutorial
SQL Database
SQL Table
SQL Select
SQL Order By
SQL Insert
SQL Update
SQL Delete
Difference
SQL Injection
SQL String Functions
Miscl
- SQL Formatter
- SQL group by
- SQL add/drop/update column operation
- SQL CAST Function
- SQL Comments
- SQL CONCAT Function
- CTE (Common Table Expression)SQL
- How to use distinct in SQL?
- Joining Three or More Tables in SQL
- What is Web SQL?
- How to create functions in SQL?
- How to run SQL Script?
- How to Delete Duplicate Rows in SQL?
- Nth Highest salary
- 12 Codd's Rules
- SQL EXCEPT
- Types of SQL JOIN
- Change datatype of column in SQL
- SQL Auto Increment
- SQL Like
- Commit and Rollback in SQL
- SQL Concatenate
- SQL get month from the date
- Savepoint in SQL
- SQL ORDER BY DATE
- TIME Datatype in SQL
- SQL BETWEEN
- CRUD Operations in SQL
- SQL INDEX
- Scalar Functions in SQL
- SET Operators in SQL
- Types of SQL Commands
- TCL Commands in SQL
- SQL Subquery
- SQL View
- Constraints in SQL
- Pattern Matching in SQL
- SQL Date Functions
- DDL Commands in SQL
- DML Commands in SQL
- SQL CASE
- SQL Inner Join
- SQL IN Operator
- Check Constraint in SQL
- SQL CLAUSES
- SQL LOGICAL OPERATORS
- Delete Column from Table
- Add Column in the Table
- Delete one row in SQL
- Change the Column Value
- How to Add Foreign Key in SQL
- Add a Primary Key
- Insert One or More rows
- How to Use LIKE in SQL
- Cursor in SQL
- Difference Between DROP and Truncate
- SQL Comparison Operators
- SQL COUNT WHERE
- SQL SELECT MIN
- SQL Stored Procedure
- SQL SELECT AVG
- SQL SELECT MAX
- SQL ADD COLUMN
- How to use Auto-Increment in SQL
- SQL Languages
- SQL Arithmetic Operators
- How to Use GROUP BY in SQL
- How to Use ORDER BY in SQL
- Trigger in SQL
- What is Race Condition
- SQL COUNT DISTINCT
PL/SQL Tutorial
Sql Interview Question
SQl Quiz
SQL Comments
SQL Comments are used to explain the sections of the SQL statements, and used to prevent the statements of SQL. In many programming languages, comments matter a lot.
A Microsoft Access database does not support the comments. So, Mozilla Firefox and Microsoft Edge use the Microsoft Access database in the examples.
There are three types of comments, which are given below:
- Single line comments.
- Multi-line comments
- Inline comments
Single Line Comment
Comments starting and ending with a single line are said as individual line comments. The line which starts with '–' is a single line comment, and that particular line is not executed.
The text between -- and end of the line is ignored and cannot be executed.
Syntax:
- -- single-line comment
- -- another comment
- SELECT * FROM Customers;
The following example uses a single-line comment:
Example 1
SELECT * FROM Employees;
The given example uses a single-line comment to ignore the end of the line:
Example 2
The following example uses the single-line comment to ignore the statements:
Example 3
SELECT * FROM Products;
Multi-line Comments
Comments that start in one line and end in different front are said as multi-line comments. The text between /* and */ is ignored in the code part.
The line starting with '/*' is considered as a starting point of comment and terminated when '*/' lies at the end.
Syntax:
another comment */
SELECT * FROM Customers;
Example 1
of all the records
in the Customers table:*/
SELECT * FROM Employees;
The below example uses a multi-line comment to ignore more statements:
Example 2
SELECT * FROM Products;
SELECT * FROM Orders;
SELECT * FROM Categories;*/
SELECT * FROM Suppliers;
To ignore some part of a statement, use the /*....... */ comment.
The following example uses a comment to ignore some part of any code:
Example of SQL Multi-line Comment:
SELECT * FROM Products;
SELECT * FROM Orders;
SELECT * FROM Categories;*/
SELECT * FROM Suppliers;
Example
The following example uses a comment to not to be the part of a statement:
Example
OR CustomerName LIKE 'R%' /*OR CustomerName LIKE 'S%'
OR CustomerName LIKE 'T%'*/ OR CustomerName LIKE 'W%')
AND Country='America.'
ORDER BY CustomerName;
Inline comments:
Inline comments are an extension of multi-line comments, and comments can be stated between the statements and are enclosed in between '/*' and '*/.'
Syntax:
Examples:
/* SELECT * FROM Teachers;
SELECT * FROM Teacher_DETAILS;
SELECT * FROM Orders; */
SELECT * FROM Course;
In line comment ->
SELECT * FROM /* Employee_DETAILS;
SELECT * FROM Orders;
SELECT * FROM */ Topics;
SQL Comment Indicators
SQL Comment Indicator is indicated according to the given examples
It includes the double hyphen ( — ), braces ( { } ), and C-style ( /* . . . */ ) comment delimiters. It also includes the comments after the statement.
SELECT * FROM employee; {Selects all rows and columns}
SELECT * FROM employee; /*Selects all columns and rows*/copy to the clipboard
In the below examples, we place the comments on a single line code -
-- Selects all the rows and columns
SELECT * FROM employee;
{Selects all columns and rows}
SELECT * FROM customer;
/*Selects all columns and rows*/
Examples of multi-line statements -
-- Selects all columns and rows
-- from the customer table
SELECT * FROM customer;
{Selects all columns and rows
from the customer table}
SELECT * FROM customer;
/*Selects all columns and rows
from the customer table*/copy to clipboard
SELECT * -- Selects all columns and rows
FROM customer; -- from the customer table
SELECT * {Selects all columns and rows}
FROM customer; {from the customer table}
SELECT * /*Selects all columns and rows*/
FROM customer; /*from the customer table*/copy to clipboard