In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "mysql add column sentence how to express", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's train of thought slowly in depth, together to study and learn "mysql add column sentence how to express" it!
The statement that mysql adds columns is "ALTER TABLE" and the syntax is "ALTER TABLE table name ADD new column name data type [constraint] [FIRST];". The FIRST keyword is optional, adding columns at the end of the table if omitted, or at the beginning of the table if not omitted.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
A MySQL data table is made up of rows and columns. The "column" of the table is usually called a Field, and the "row" of a table is called a Record. As the business changes, you may need to add new fields (columns) to existing tables.
In mysql, the statement to add columns is "ALTER TABLE"; this statement can change the structure of the original table, such as adding or deleting columns, changing the original column type, renaming columns or tables, and so on.
Add the syntax format of the column:
ALTER TABLE table name ADD new column name data type [constraint] [FIRST]
The syntax format is described as follows:
The name of the table is the name of the data table
The new column name is the name of the column (field) to be added
The data type is the data type in which the field to be added can store data.
[constraints] are optional and are used to constrain added fields.
[FIRST] is optional to add columns at the beginning of the table; if omitted, columns are added at the end of the table by default
Example: we have a student data table whose table structure looks like this
Use the ALTER TABLE statement to add a field of type INT age at the end
ALTER TABLE student ADD age INT (4)
View a table structure
You can see that the age field has been added to the student table, and the field is in the last location of the table. The field was added successfully.
Now, try using the FIRST keyword to add a field of type INT stuId to the first column of the table
ALTER TABLE student ADD stuId INT (4) FIRST
View a table structure
As you can see, the stuId field has been added to the student table, and the field is in the first position in the table. The field was added successfully.
Thank you for your reading, the above is the content of "mysql add column sentence how to express", after the study of this article, I believe you have a deeper understanding of how to express the sentence of mysql column, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
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.