MySQL字符集操作

1.查看编码

      show variables like 'character%';

2.临时设置编码

1.set names xxx
      set names ${编码};


"set names xxx"一条命令相当于以下三条命令:

      set character_set_client = xxx;
      set character_set_connection = xxx;
      set character_set_results = xxx;

3.元数据编码


1)修改表编码

    alter table ${表名} default character set ${编码};


2)修改字段编码

    alter table ${表名} change ${字段1} ${字段2} varchar(36) character set {编码};


3)转换表所有字段编码

    alter table ${表名} convert to character set ${编码};


4)查看数据库编码格式

      show variables like 'character_set_database';


5)查看表编码格式

    show create table ${表名};


6)创建/修改数据库时指定编码

    create/alter database ${数据库名} character set ${编码};

你可能感兴趣的:(MySQL字符集操作)