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

How to view comments in mysql

青灯夜游
青灯夜游Original
2021-12-07 11:09:527437browse

Mysql method to view comments: 1. Use the "SHOW CREATE TABLE table name;" statement to view table comments; 2. Use the "SHOW FULL COLUMNS FROM table name;" statement to view field comments.

How to view comments in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

Let me give you a demonstration. Create a student table here. The code is as follows:

CREATE TABLE `student` (
`id` int(11) AUTO_INCREMENT PRIMARY KEY COMMENT '学好',
`name` varchar(32) NOT NULL DEFAULT '' COMMENT '姓名',
`sex` tinyint(1) NOT NULL COMMENT '性别',
`age` tinyint(4) NOT NULL COMMENT '年龄',
`class` varchar(32) NOT NULL DEFAULT '' COMMENT '班级'
)ENGINE=InnODB CHARSET=utf8 COMMENT='学生表';

How to view comments in mysql

View the comments of the table

The code is as follows:

SHOW CREATE TABLE `student`;

How to view comments in mysql

Modify the comments of the table

The code is as follows:

ALTER TABLE `student` COMMENT '学生表2.0';

Result As shown in the picture:

How to view comments in mysql

How to view comments in mysql

Modify the comment of the field

The code is as follows:

ALTER TABLE `student` MODIFY COLUMN `id` COMMENT '学号';

How to view comments in mysql

View the comments of the field

The code is as follows:

SHOW FULL COLUMNS  FROM `student`;

The result is as shown in the figure:

How to view comments in mysql

[Related recommendations: mysql video tutorial]

The above is the detailed content of How to view 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