查看mysql數(shù)據(jù)庫及表編碼格式1.查看數(shù)據(jù)庫編碼格式
2.查看數(shù)據(jù)表的編碼格式
3.創(chuàng)建數(shù)據(jù)庫時(shí)指定數(shù)據(jù)庫的字符集 mysql>create database <數(shù)據(jù)庫名> character set utf8; 4.創(chuàng)建數(shù)據(jù)表時(shí)指定數(shù)據(jù)表的編碼格式 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.修改數(shù)據(jù)庫的編碼格式 mysql>alter database <數(shù)據(jù)庫名> character set utf8; 6.修改數(shù)據(jù)表格編碼格式 mysql>alter table <表名> character set utf8; 7.修改字段編碼格式 mysql>alter table <表名> change <字段名> <字段名> <類型> character set utf8; mysql>alter table user change username username varchar(20) 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 <外鍵名>;
|
|