Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to annotate mysql tables

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to annotate the mysql table", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to annotate the mysql table" this article.

Mysql table to add comments: 1, in the field definition creation table script to add comment attribute to add comments; 2, use the command to modify the field, and then add comment attribute definition to add comments.

This article operating environment: Windows7 system, mysql5.5 version, Dell G3 computer.

MySQL add comment

In database design, it is recommended to add comments for databases, data tables and data fields. In MySQL databases, comments for fields or columns are added with the property comment.

In the script that creates the new table, you can add the comment attribute to the field definition creation table script to add comments.

The sample code is as follows:

1 create table test (2 id int not null default 0 comment 'user id')

If you have already built the table, you can also use the command to modify the field, and then add the comment attribute definition, you can add comments.

The sample code is as follows:

1 alter table test 2 change column id id int not null default 0 comment 'Test Table id'

Check the comments for all the fields of the existing table?

You can view it with the command: show full columns from table_name. Examples are as follows:

1 show full columns from test; write comments 1 create table test1 (2 field_name int comment 'field comment' 3) comment=' table comments when creating the table; modify table notes 1 alter table test1 comment 'modified table comments'; modify field comments 1 alter table test1 modify column field_name int comment 'modified field comments' 2 3-Note: method 1 for field names and field types to view table comments-- 2 show create table test1; 3 in generated SQL statements-- 4 use information_schema; 5 select * from TABLES where TABLE_SCHEMA='my_db' and TABLE_NAME='test1'\ G method for viewing field comments in metadata table 1-- show 2 show full columns from test1 3-see 4 select * from COLUMNS where TABLE_SCHEMA='my_db' and TABLE_NAME='test1'\ G above in the metadata table is all the contents of the article "how to annotate the mysql Table". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report