In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to use the alter table statement to modify the table structure in the MySQL database. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
As we all know, MySQL databases are often combined with PHP to develop powerful applications. So for those of us who are new to PHP programming, it is necessary to understand some simple operations of MySQL databases. The following editor will explain how the MySQL database uses the alter table statement to modify the table structure.
How to use alter table statement to modify table structure in MySQL database
1. Add column
Altertabletbl_nameaddcol_nametype
For example, add a column of weight to pet's table
Mysql > altertablepetaddweightint
two。 Delete column
Altertabletbl_namedropcol_name
For example, delete the column weight in the pet table
Mysql > altertablepetdropweight
How to use alter table statement to modify table structure in MySQL database
3. Change column
It is divided into changing the properties of the column and changing the name of the column.
Change the properties of the column-method 1:
Altertabletbl_namemodifycol_nametype
For example, change the type of weight
Mysql > altertablepetmodifyweightvarchar (30)
Change the properties of the column-method 2:
Altertabletbl_namechangeold_col_namecol_nametype
For example, change the type of weight
Altertablepetchangeweightweightvarchar (30)
Change the name of the column:
Altertabletbl_namechangeold_col_namecol_name
For example, change the name of weight in the pet table:
Mysql > altertablepetchangeweightwei
4. Change the name of the watch
Altertabletbl_namerenamenew_tbl
For example, rename the pet table to animal
Mysql > altertablepetrenameanimal; on "MySQL database how to use alter table statements to modify the table structure" this article shares here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
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.