我正在尝试运行一个查询,其中包括将unicode
字符串与某些列进行比较。为此,我需要为类型为DATETIME
的列更改字符集和字符编码。但是当我执行以下查询时:
ALTER TABLE licenses CHANGE expires_at expires_at DATETIME DEFAULT NULL CHARACTER SET utf8 COLLATE utf8_unicode_ci;
我收到错误:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHARACTER SET utf8 COLLATE utf8_unicode_ci' at line 1
但是对于以下查询(改变类型为VARCHAR
的列的字符集),效果非常好:
ALTER TABLE customers CHANGE DEFAULT NULL name name VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
如何更改DATETIME
类型的mysql列的字符集?