1.查看数据库编码格式
mysql> show variables like 'character_set_database';
2.查看数据表的编码格式
mysql> show create table ;
3.创建数据库时指定数据库的字符集
mysql>create database character set utf8;
4.创建数据表时指定数据表的编码格式
create table tb_books ( name varchar(128) not null, price double not null, bookCount int not null, author varchar(128) not null ) default charset = utf8;
5.修改数据库的编码格式
mysql>alter database character set utf8;
6.修改数据表格编码格式
mysql>alter table character set utf8;
7.修改字段编码格式
mysql>alter table change character set utf8;mysql>alter table user change username username varchar(128) character set utf8 not null;
8.添加外键
mysql>alter table tb_product add constraint fk_1 foreign key(factoryid) references tb_factory(factoryid);mysql>alter table add constraint foreign key REFERENCES ;
9.删除外键
mysql>alter table tb_people drop foreign key fk_1;mysql>alter table drop foreign key ;