Mysql change column name from “group” to “group_code”

ぐ巨炮叔叔 提交于 2019-12-11 03:32:47

问题


I have set a column name to "group", which turned out to be a reserved word. Now I try to change the name to "group_code", but I get an error. I try:

ALTER TABLE task_values CHANGE group group_code VARCHAR(40) NOT NULL;

and

ALTER TABLE task_values CHANGE 'group' group_code VARCHAR(40) NOT NULL;

but both fail, I get "No such element" error. Please help


回答1:


You will need to use backticks around group which, as you said, is a mysql reserved keyword

ALTER TABLE task_values CHANGE `group` group_code VARCHAR(40) NOT NULL;


来源:https://stackoverflow.com/questions/22518032/mysql-change-column-name-from-group-to-group-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!