show variables like 'character_set_database';
2. View the encoding format of the data table
show create table <table name>;
3. Specify the character set of the database when creating the database
create database <database name> character set utf8;
4 .Specify the encoding format of the data table when creating the data table
create table tb_books (
name varchar(45) not null,
price double not null,
bookCount int not null,
author varchar(45) not null ) default charset = utf8;
5. Modify the database The encoding format
alter database <database name> character set utf8;
6. Modify the data table encoding format
alter table <table name> character set utf8;
7. Modify the field encoding format
alter table <table name> change <field name> <field name > <type> character set utf8;
alter table user change username username varchar(20) character set utf8 not null;
8. Add foreign key
alter table tb_product add constraint fk_1 foreign key(factoryid) references tb_factory(factoryid);
alter table <table name> add constraint <foreign key name > foreign key<field name> REFERENCES <foreign table name><field name>;
9. Delete foreign key
alter table tb_people drop foreign key fk_1;
alter table <table name> drop foreign key <foreign key name>;