Method: 1. Use the "show create table table name;" statement to view table comments; 2. Use the "select*from TABLES where TABLE_SCHEMA='database name' and TABLE_NAME='table name'" statement to view the table Note.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How to view table comments in mysql
How to view table comments
--Look in the generated SQL statement View the DDL generated by the table Note: Do not add single quotes to the table name
show create table 表名;
– Look in the metadata table
use information_schema; select * from TABLES where TABLE_SCHEMA='数据库名' and TABLE_NAME='表名'
Extension:
Write comments when creating the table
create table t_user( ID INT(19) primary key auto_increment comment '主键', NAME VARCHAR(300) comment '字段的注释', CREATE_TIME date comment '创建时间' )comment = '表的注释';
Modify the comments of the table
alter table 表名 comment '修改后的表的注释';
Modify the comments of the field
alter table 表名 modify column 字段名 字段类型 comment '修改后的字段注释';
--Note: Just write the field name and field type. If there is a specified length before, you must also specify it here.
For example: alter table t_cal_res_channel MODIFY column resume_channel varchar(30) COMMENT 'channel'
Recommended learning: mysql video tutorial
The above is the detailed content of How to view table comments in mysql. For more information, please follow other related articles on the PHP Chinese website!