1. View the database encoding format
like ' Character_set_database ';
2. View the encoding format of the data table
Create Table < table name >;
3. Specify the character set of the database when creating the database
Create Database < database name >characterset UTF8;
4. Specify the encoding format of the data table when creating the data table
Create TableTb_books (Namevarchar( $) not NULL, PriceDouble not NULL, Bookcountint not NULL, authorvarchar( $) not NULL)defaultCharSet=UTF8;
5. Modify the encoding format of the database
Alter Database < database name >characterset UTF8;
6. Modify the data table encoding format
Alter Table < table name >characterset 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 ( Span style= "color: #800000; Font-weight:bold ">20 ) character set UTF8 not null ;
8. Add a FOREIGN key
Alter TableTb_productAdd constraintFk_1Foreign Key(Factoryid)Referencestb_factory (Factoryid);Alter Table <Table name> Add constraint <FOREIGN Key Name> Foreign Key<Field name> REFERENCES <Appearance table name><Field name>;
9. Delete foreign keys
Alter Table Drop Foreign Key Fk_1; Alter Table < table name >dropforeignkey< foreign key name >;
View MySQL's encoding format