Home > Database > Mysql Tutorial > How to set field comments in mysql

How to set field comments in mysql

青灯夜游
Release: 2022-01-05 16:32:13
Original
9604 people have browsed it

Setting method: 1. Use the "create table table name (field name field type comment 'field comment');" statement; 2. Use "alter table table name modify column field name field type comment 'field The comment ';' statement.

How to set field comments in mysql

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

In the MySQL database, comments on fields or columns are added using the comment attribute.

In the script that creates a new table, you can add comments by adding the comment attribute in the field definition script.

Write field comments when creating a table

create table test1 ( 
    field_name int comment '字段的注释' 
);
Copy after login

Modify field comments

alter table test1 modify column field_name int comment '修改后的字段注释'; 

-- 注意:字段名和字段类型照写就行
Copy after login

View field comments Method

-- show 
	show  full  columns  from  test1; 
-- 在元数据的表里面看 
	select * from COLUMNS where TABLE_SCHEMA='my_db' and TABLE_NAME='test1' \G
Copy after login

[Related recommendations: mysql video tutorial]

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