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

How to add comments to table in mysql

王林
Release: 2020-09-10 16:08:49
Original
15508 people have browsed it

Mysql method to add comments to the table: You can use the comment keyword to add, the specific method is [create table user(in int, name varchar(30))comment = 'User information table';].

How to add comments to table in mysql

#In MySQL, add comments to tables and fields using the COMMENT keyword.

Related learning recommendations: mysql tutorial (video)

1. Add comments on tables and fields

Create a data table At the same time, add comments to tables and fields.

CREATE TABLE tb_user
(
	id INT AUTO_INCREMENT PRIMARY KEY COMMENT '编号',
	name VARCHAR(30) COMMENT '姓名'
)COMMENT = '用户信息表';
Copy after login

2. Modify table comments

ALTER TABLE tb_user COMMENT '用户信息表2';
Copy after login

3. Modify field comments

Modifying field comments is actually modifying the definition of the field.

ALTER TABLE tb_user MODIFY COLUMN name VARCHAR(30) NOT NULL COMMENT '姓名2';
Copy after login

Note: When modifying, you must write the complete definition of the field, such as field type, attributes, etc. Never overwrite other attributes defined in this field just to modify a comment.

This article comes from the php Chinese website mysql graphic tutorial channel, welcome to learn!

4. Query field information

SHOW FULL COLUMNS FROM tb_user;
Copy after login

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