First, view the database encoding format
Mysql> Show variables like ' character_set_database ';
Second, view the data table encoding format
Mysql> Show CREATE table < table name >;
Specifying the character set of a database when creating a database
Mysql>create DB < database name > character set UTF8;
The encoding format of the specified datasheet when you create the datasheet
CREATE TABLE Tb_books (
name varchar) NOT NULL, price
double not NULL,
Bookcount int is not NULL,
author V Archar () NOT null) default CharSet = UTF8;
V. Modify the encoding format of the database
Mysql>alter DB < database name > character set UTF8;
Six, modify the data table encoding format
Mysql>alter Table < name > character set UTF8;
Modify the field encoding format
Mysql>alter table < table name > change < Field name > < Field name > < type > Character set UTF8;
Mysql>alter Table User change username username varchar (a) character set UTF8 not null;
Eight, add foreign key
Mysql>alter table tb_product Add constraint fk_1 foreign key (Factoryid) references tb_factory (Factoryid);
Mysql>alter table < table name > Add constraint < foreign key name > Foreign key< Field name > REFERENCES < external table name >< field name >;
Ix. Delete foreign keys
Mysql>alter table tb_people drop foreign key fk_1;
Mysql>alter table < table name > drop FOREIGN Key < foreign key name >;
Summarize
The above is the entire content of this article, I hope this article's content for everyone to learn or use MySQL can help, if there is doubt you can message exchange, thank you for the cloud Habitat Community support.