Computer >> Computer tutorials >  >> Programming >> MySQL

How to add comments in MySQL Code?


We can add comments in MySQL with the help of # symbol. Whenever we write # symbol before any sentence, the whole line will be ignored by MySQL.

MySQL supports three type of comments −

1. With the help of # symbol

mysql> create table CommentDemo
   -> (
   -> id int   #Id is an integer type
   -> );
Query OK, 0 rows affected (0.65 sec

Above, we have set the comment as

#Id is an integer type

2. With the help of -- symbol

mysql> create table CommentDemo2
   -> (
   -> id int -- id is an integer type
   -> );
Query OK, 0 rows affected (0.49 sec)

Above, we have set the comment as −

- id is an integer type

3. With the help of /* */ symbol

This is for multiple line comments, same as C or C++ language.

mysql> create table CommentDemo3
   -> (
   -> /*id is an integer type */
   -> id int
   -> );
Query OK, 0 rows affected (0.52 sec)

Above, we have set multi-line comment as

/*id is an integer type */