In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-10-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Today, I will talk to you about how to achieve alter operation in mysql, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
-- add a column ALTER TABLE `users`ADD `username` to a table
TEXT NOT NULL;-- such as alter table app_user add starLevel INT (11) NULL default 6;-- when creating a table
Add the default value create table tablename to a column
(columnname datatype default defaultvalue);-- built table modify alter table tablename alter column columnname set default defaultvalue;-- add a unique constraint Alter table user add unique (username) to the username of the user table;-- change the digest field in the app_ activity table to allow empty ALTER TABLE app_activity MODIFY digest VARCHAR (255i) null;-- Delete a field ALTER TABLE mytable DROP field
Name;-- modify the type of column alter table table name
Change field name field name field type [whether non-null is allowed];-- change table name rename table old table name to new table name; / / add utf8 coding library, delete a database CREATE DATABASE `test` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;DROP database test; / / delete the name of an index alter table table name drop index index column; / / View the field information of the table: desc table name; / / view all information of the table: show create table table name / / add primary key constraint: alter table table name add constraint primary key (primary key field); / / add foreign key constraint: alter table from table add constraint foreign key (foreign key field) references (primary key field); / / delete primary key constraint: alter table table name drop primary key;// remove foreign key constraint: alter table table name drop foreign key foreign key (case sensitive) / / Delete a unique constraint (username there is a unique constraint on this column, app_user is the table name) drop index username on app_user
After reading the above, do you have any further understanding of how to implement alter operation in mysql? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.