In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge of this article "mysql how to add fields and comments", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to add fields and notes to mysql" article.
In mysql, you can use the ALTER TABLE statement to add fields and comments, which can add or modify data tables with the syntax "ALTER TABLE table name ADD field name type COMMENT 'comment content;"; ADD is used to add data, and COMMENT is used to represent the comment content.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How to add fields and comments to mysql
Add field keyword alter comment keyword comment
The role of ALTER TABLE
The ALTER TABLE command is used to add, delete, or change columns in an existing data table.
The syntax is
ALTER TABLE table name ADD field name varchar (20) COMMENT 'comment content'
No comments, just get rid of comment
An example of adding fields is as follows:
Alter table user add COLUMN new1 VARCHAR (20) DEFAULT NULL; / / add a field, default is empty alter table user add COLUMN new2 VARCHAR (20) NOT NULL; / / add a field, default cannot be empty
If it is a table that has been built, you can use the command to modify the field, plus the comment attribute.
For example:
Alter table users modify name varchar (20) not null comment 'username'
Here users is the table name, name is the field name, varchar (20) is the type, and not null is the constraint.
The above is about the content of this article on "how to add fields and comments in mysql". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please 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: 285
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.