是的,可以使用#符号。让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY , # Creating a sequence Number -> FirstName varchar(20), # Creating a column to store name -> Age int # creating a column to store an age -> );
上面,我们使用#符号设置了注释。使用insert命令在表中插入一些记录。我们还将在插入语句中使用相同的#符号设置注释-
mysql> insert into DemoTable(FirstName,Age) values('Chris',21); mysql> insert into DemoTable(FirstName,Age) values('David',23); # Inserting to store Firstname and age. mysql> insert into DemoTable(FirstName,Age) values('Bob',24); # Inserting to store Firstname and age.
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+----+-----------+------+ | Id | FirstName | Age | +----+-----------+------+ | 1 | Chris | 21 | | 2 | David | 23 | | 3 | Bob | 24 | +----+-----------+------+ 3 rows in set (0.00 sec)