In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 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.
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.