Home >Database >Mysql Tutorial >How to view table comments in mysql

How to view table comments in mysql

WBOY
WBOYOriginal
2021-12-28 14:49:3511454browse

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.

How to view table comments in mysql

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!

Statement:
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
Previous article:What is the view of mysqlNext article:What is the view of mysql