Last active
May 21, 2016 22:17
-
-
Save eiryu/5b7de163e501573dc7e6 to your computer and use it in GitHub Desktop.
テーブルの文字コード変換でデータ型が変わってしまう
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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