In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the use of comment in mysql, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
In the MySQL database, comments for fields or columns are added with the property comment.
In the script that creates the new table
You can add comments by adding the comment attribute to the field definition script.
The sample code is as follows:
Create table test (id int not null default 0 comment 'user id')
If it is a table that has already been built
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:
Alter table testchange 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 tablename
Examples are as follows:
Show full columns from test
1 write comments when creating the table
Create table test1 (comments for field_name int comment 'field') comments for the comment=' table'
2 modify the comments of the table
Alter table test1 comment 'comments on modified tables'
3 modify the comments of the field
Alter table test1 modify column field_name int comment 'modified field comments';-- Note: just write the field name and field type.
4 the method of viewing the comments of the table
-- look at show create table test1;-- in the generated SQL statement and look at use information_schema;select * from TABLES where TABLE_SCHEMA='my_db' and TABLE_NAME='test1'\ G in the metadata table.
5 ways to view field comments
-- showshow full columns from test1;-- look at select * from COLUMNS where TABLE_SCHEMA='my_db' and TAB in the metadata table. The above are all the contents of how to use comment in mysql. 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.