Home > Database > Mysql Tutorial > How to add field comments to mysql table

How to add field comments to mysql table

coldplay.xixi
Release: 2020-10-10 16:56:46
Original
7572 people have browsed it

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

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';
Copy after login

How to add field comments to mysql table

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template