`

A sample to update mysqm column charecter set

阅读更多

mysql> SHOW CHARACTER SET LIKE 'latin%';
+---------+-----------------------------+-------------------+--------+
| Charset | Description                 | Default collation | Maxlen |
+---------+-----------------------------+-------------------+--------+
| latin1  | cp1252 West European        | latin1_swedish_ci |      1 |
| latin2  | ISO 8859-2 Central European | latin2_general_ci |      1 |
| latin5  | ISO 8859-9 Turkish          | latin5_turkish_ci |      1 |
| latin7  | ISO 8859-13 Baltic          | latin7_general_ci |      1 |
+---------+-----------------------------+-------------------+--------+
4 rows in set (0.01 sec)

mysql> alter table user modify user_name varchar(20) character set utf8
    -> ;
Query OK, 12 rows affected (0.00 sec)
Records: 12  Duplicates: 0  Warnings: 0


mysql> show full columns from user;
+-------------+-------------+-------------------+------+-----+---------+----------------+---------------------------------+---------+
| Field       | Type        | Collation         | Null | Key | Default | Extra          | Privileges                      | Comment |
+-------------+-------------+-------------------+------+-----+---------+----------------+---------------------------------+---------+
| user_id     | int(11)     | NULL              | NO   | PRI | NULL    | auto_increment | select,insert,update,references |         |
| user_name   | varchar(20) | utf8_general_ci   | YES  |     | NULL    |                | select,insert,update,references |         |
| department  | varchar(20) | latin1_swedish_ci | NO   |     | NULL    |                | select,insert,update,references |         |
| password    | varchar(20) | latin1_swedish_ci | NO   |     | NULL    |                | select,insert,update,references |         |
| role        | varchar(20) | latin1_swedish_ci | NO   |     | NULL    |                | select,insert,update,references |         |
| last_login  | datetime    | NULL              | NO   |     | NULL    |                | select,insert,update,references |         |
| supervisor  | varchar(20) | utf8_unicode_ci   | YES  |     | NULL    |                | select,insert,update,references |         |
| login_count | bigint(20)  | NULL              | NO   |     | NULL    |                | select,insert,update,references |         |
| icon_id     | bigint(20)  | NULL              | YES  |     | NULL    |                | select,insert,update,references |         |
+-------------+-------------+-------------------+------+-----+---------+----------------+---------------------------------+---------+
9 rows in set (0.00 sec)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics