SQLite | SQLite Basic Knowledge | Writing Comments in SQL Statements

This page explains the formats used to write comments in SQL statements.

Writing Comments

When you want to leave notes or explanations in SQL statements, SQLite provides the following two ways to add comments to SQL statements.

-- comment

/* comment */

Comments are ignored when SQL statements are executed, so they do not affect the execution result.

When you write a comment in the -- comment format, the text from -- to the end of the line becomes a comment. For example, write it as follows.

select * from user; -- list
sqlite> select * from user; -- list
1|devkuma
2|araikuma
sqlite>

When you write a comment in the /* comment */ format, the text from /* to */ becomes a comment.

select * from /* comment */ user;
sqlite> select * from /* comment */ user;
1|devkuma
2|araikuma
sqlite>

You may not write comments very often in the command-line tool, but comments are useful when you write multiple SQL statements in an external file and then import and execute them in SQLite.