56,677
社区成员
发帖
与我相关
我的任务
分享
mysql> CREATE TABLE `A` (`username` char(10) CHARACTER SET utf8 NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.14 sec)
mysql> alter table `A` convert to character set gbk;
Query OK, 0 rows affected (0.16 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table `A`;
+-------+---------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------+
| A | CREATE TABLE `a` (
`username` char(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk |
+-------+---------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> CREATE TABLE `A` (
-> `username` char(10) CHARACTER SET utf8 NOT NULL,
-> `password` varchar(32) CHARACTER SET utf8 NOT NULL
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> ALTER TABLE `A` DEFAULT CHARACTER SET gbk ,
-> modify `username` char(10) CHARACTER SET gbk NOT NULL,
-> modify `password` varchar(32) CHARACTER SET gbk NOT NULL;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table `A`;
+-------+--------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table
|
+-------+--------------------------------------------------------------------------------------------------------------------------+
| A | CREATE TABLE `a` (
`username` char(10) NOT NULL,
`password` varchar(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk |
+-------+--------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
其实官方文档上也都有参考.看明白了就行.