Comments
Published May 6, 2021Updated Sep 9, 2021
Contribute to Docs
A comment is a piece of text within a program that is not executed. It can be used to provide additional information to aid in understanding the code, or to prevent execution of SQL statements.
Single-line Comments
Single line comments start with --
. Any text between --
and the end of the line will be ignored (will not be executed).
The following example uses a single-line comment as an explanation:
-- Select all:SELECT *FROM customers;
Multi-line Comments
Multi-line comments start with /*
and end with */
.
Any text between /*
and */
will be ignored.
The following example uses a multi-line comment as an explanation:
/* Select everythingfrom the customers table */SELECT *FROM customers;
The following example uses a multi-line comment to ignore many statements:
/* SELECT *FROM customers;SELECT *FROM products; */SELECT *FROM orders;
To ignore just a part of a statement, also use the /*
*/
comment.
The following example uses a comment to ignore part of a line:
SELECT id, customer_name, /* city, */ countryFROM customers;
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn SQL on Codecademy
- Skill path
Analyze Data with SQL
Learn to analyze data with SQL and prepare for technical interviews.Includes 9 CoursesWith CertificateBeginner Friendly17 hours - Free course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner Friendly5 hours