Home >Database >Mysql Tutorial >How to add field comments to mysql table
How to add field comments to mysql table: add fields directly when creating the table, the code is [CREATE TABLE userinfo(id INT COMMENT 'number',uname VARCHAR(40) COMMENT 'username',].
How to add field comments to mysql table:
Directly post the code and case
#创建表的时候写注释 CREATE TABLE userinfo( id INT COMMENT '编号', uname VARCHAR(40) COMMENT '用户名', address VARCHAR(120) COMMENT '家庭住址', hobby VARCHAR(200) COMMENT '爱好' )COMMENT = '用户信息表'; #修改表的注释 ALTER TABLE userinfo COMMENT '用户信息资料表'; #修改字段的注释,注意:字段名和字段类型照写就行 ALTER TABLE userinfo MODIFY COLUMN uname VARCHAR(40) COMMENT '姓名'; #查看表注释的方法,在生成的SQL语句中看 SHOW CREATE TABLE userinfo; #在元数据的表里面看 USE information_schema; SELECT * FROM TABLES WHERE TABLE_SCHEMA='shoppingcart' AND TABLE_NAME='userinfo'; #查看字段注释的方法 SHOW FULL COLUMNS FROM userinfo; #在元数据的表里面看 SELECT * FROM COLUMNS WHERE TABLE_SCHEMA='shoppingcart' AND TABLE_NAME='userinfo';
Related free learning recommendations: mysql database (video)
The above is the detailed content of How to add field comments to mysql table. For more information, please follow other related articles on the PHP Chinese website!