I have found there is the 'comment' keyword in MySQL.(not comment syntax like /* */, #)
But I do not know the reason why there is the 'comment' keyword.
If there is the following table, how could I use the 'comment'?
create table Employee(
id int not null auto_increment,
create_dt date comment 'the date when employee was hired'
salary int comment 'salary in EUR',
primary key (id)
) comment 'The employee table of company AA';
Purpose. Use the COMMENT statement to add a comment about a table, view, materialized view, or column into the data dictionary. To drop a comment from the database, set it to the empty string ' '. See Also: "Comments" for more information on associating comments with SQL statements and schema objects.
Syntax Using /* and */ symbols In MySQL, a comment that starts with /* symbol and ends with */ and can be anywhere in your SQL statement. This method of commenting can span several lines within your SQL.
mysql> SELECT 1+1; # This comment continues to the end of line mysql> SELECT 1+1; -- This comment continues to the end of line mysql> SELECT 1 /* this is an in-line comment */ + 1; mysql> SELECT 1+ /* this is a multiple-line comment */ 1; Nested comments are not supported.
Comments are a way to store relevant information in the database itself. For example, putting a comment on a column will cause it to be displayed by the show create table
and show full columns
commands.
Note that this is different to what most people think of as comments in SQL - those are simply statements in scripts that are ignored after being parsed. They do not make their way into any metadata for later retrieval.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With