By the by, if you have an existing table that has been specified wrongly, you *CAN* alter it.
How to tell? Use the
SHOW CREATE TABLE yourtablename; command.
It will dump out the table and show you the CHARSET default for the entire table and the character set of each field, if different than the table default.
For example:
Code:
mysql> show create table xxx;
+-------+----------------------------------------
| Table | Create Table
+-------+----------------------------------------
| xxx | CREATE TABLE `xxx` (
`name` varchar(100) DEFAULT NULL,
`email` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+----------------------------------------
Okay, so that table has two fields and both use the DEFAULT for the table character set of "latin1".
So I can do:
Code:
mysql> alter table xxx modify name varchar(100) charset utf8;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table xxx;
+-------+--------------------------------------------------------------------
| Table | Create Table
+-------+--------------------------------------------------------------------
| xxx | CREATE TABLE `xxx` (
`name` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`email` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+--------------------------------------------------------------------
See? The table still defaults to "latin1"--and that means the EMAIL field will be "latin1". But the NAME field is now UTF8 and so can hold Unicode characters.
Easy with MySQL!