Home > Database > Mysql Tutorial > body text

How to view table comments in mysql

WBOY
Release: 2021-12-28 14:49:35
Original
11429 people have browsed it

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

– Look in the metadata table

use information_schema;
select * from TABLES where TABLE_SCHEMA='数据库名' and TABLE_NAME='表名'
Copy after login

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  = '表的注释';
Copy after login

Modify the comments of the table

alter table 表名 comment '修改后的表的注释';
Copy after login

Modify the comments of the field

alter table 表名 modify column 字段名 字段类型 comment '修改后的字段注释';
Copy after login

--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!

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