Home>Article>Database> How to view comments in mysql table

How to view comments in mysql table

藏色散人
藏色散人 Original
2020-11-06 10:59:18 6067browse

How to view comments in mysql tables: 1. View the comments of all tables through the "information_schema.TABLES" statement; 2. Query the comments of all tables and fields through the "information_schema. TABLES a LEFT JOIN..." statement Notes etc.

How to view comments in mysql table

Recommended: "mysql video tutorial"

Mysql View table comments or field comments

View the comments of all tables

SELECT table_name 表名, table_comment 表说明 FROM information_schema.TABLES WHERE table_schema = '数据库名' ORDER BY table_name

Query the comments of all tables and fields

SELECT a.table_name 表名, a.table_comment 表说明, b.COLUMN_NAME 字段名, b.column_comment 字段说明, b.column_type 字段类型, b.column_key 约束 FROM information_schema. TABLES a LEFT JOIN information_schema. COLUMNS b ON a.table_name = b.TABLE_NAME WHERE a.table_schema = '数据库名' ORDER BY a.table_name

Query the comments of all fields of a table

select COLUMN_NAME 字段名, column_comment 字段说明, column_type 字段类型, column_key 约束 from information_schema.columns where table_schema = '数据库名' and table_name = '表名' ;

or

show full columns from 表名;

View DDL generated by the table

Note that the table name does not include single quotes

show create table 表名;

Create a new table and add comments for tables and fields

create table t_user( ID INT(19) primary key auto_increment comment '主键', NAME VARCHAR(300) comment '姓名', CREATE_TIME date comment '创建时间' )comment = '用户信息表';

Modify comments for tables/fields

Modify table comments

alter table t_user comment = '修改后的表注释信息(用户信息表)';

Modify field comments

alter table t_user modify column id int comment '主键ID';

The above is the detailed content of How to view comments in mysql table. 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