有任何想法,如何添加专栏:
alter table tname add column cname text character set utf8 collate utf8_general_ci if not exists;
发出错误:
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 'if not exists' at line 1
我需要使用utf-8编码添加新列。
由于
答案 0 :(得分:5)
这不是ALTER TABLE的有效语法 尝试,
alter table tname add column cname text character set utf8 collate utf8_general_ci;
答案 1 :(得分:0)
在将排序规则指定给表时,您对表已经非常小心了。
alter table table_name add column column_name text character set utf8 COLLATE utf8_unicode_ci DEFAULT NULL comment 'Comment to the attachment file';