Skip to content

Instantly share code, notes, and snippets.

@eiryu
Last active May 21, 2016 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiryu/5b7de163e501573dc7e6 to your computer and use it in GitHub Desktop.
Save eiryu/5b7de163e501573dc7e6 to your computer and use it in GitHub Desktop.
テーブルの文字コード変換でデータ型が変わってしまう
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.27 |
+-----------+
1 row in set (0.00 sec)
mysql> create table a(
-> a text
-> );
Query OK, 0 rows affected (0.02 sec)
mysql> show create table a\G
*************************** 1. row ***************************
Table: a
Create Table: CREATE TABLE `a` (
`a` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
mysql> desc a;
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| a | text | YES | | NULL | |
+-------+------+------+-----+---------+-------+
1 row in set (0.01 sec)
mysql> alter table a convert to character set utf8mb4;
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table a\G
*************************** 1. row ***************************
Table: a
Create Table: CREATE TABLE `a` (
`a` mediumtext
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)
mysql> desc a;
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| a | mediumtext | YES | | NULL | |
+-------+------------+------+-----+---------+-------+
1 row in set (0.01 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment