In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
I believe many inexperienced people don't know what to do about how to use the alter sentence in MySQL. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Summary of the usage of alter sentence in MySQL
1: delete column
ALTER TABLE [table name] DROP [column name]
2: add columns
ALTER TABLE [table name] ADD [column name] INT NOT NULL COMMENT 'comment description'
3: modify the type information of the column
ALTER TABLE [table name] CHANGE [column name] [new column name (here you can use the same name as the original column)] BIGINT NOT NULL COMMENT 'comment description'
4: rename the column
ALTER TABLE [table name] CHANGE [column name] [new column name] BIGINT NOT NULL COMMENT 'comment description' www.2cto.com
5: rename the table
ALTER TABLE [Table name] RENAME [Table New name]
6: delete the primary key in the table
Alter TABLE [table name] drop primary key
7: add primary key
ALTER TABLE sj_resource_charges ADD CONSTRAINT PK_SJ_RESOURCE_CHARGES PRIMARY KEY (resid,resfromid)
8: add index
ALTER TABLE sj_resource_charges add index INDEX_NAME (name)
9: add a unique constraint index
ALTER TABLE sj_resource_charges add unique emp_name2 (cardnumber)
10: delete the index
Alter table tablename drop index emp_name
After reading the above, have you mastered how to use the alter statement in MySQL? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.