Change column name in MariaDB

痴心易碎 提交于 2019-12-08 15:27:36

问题


I have this column in this database with a spacebar included, which I want to change.

ALTER TABLE . CHANGE COLUMN `Anzahl Personen` AnzahlPersonen int(11); 

After using this line in the command line the output is as following:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHANGE COLUMN `Anzahl Personen` AnzahlPersonen int(11)' at line 1

Yeah, I have no Idea, what I am doing wrong.


回答1:


If you are using dot (.) instead of table name that is why you have error. You have to specify table name:

ALTER TABLE `table_name` CHANGE COLUMN `Anzahl Personen` AnzahlPersonen int(11);



回答2:


ALTER TABLE <table_name> CHANGE COLUMN old_name new_name column_definition

https://jira.mariadb.org/browse/MDEV-16290



来源:https://stackoverflow.com/questions/28507987/change-column-name-in-mariadb

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