gpt4 book ai didi

mysql - 删除mysql中包含空格的列

转载 作者:太空宇宙 更新时间:2023-11-04 12:40:10 24 4
gpt4 key购买 nike

我想知道如何在 mysql 中删除包含空格的列。尝试了以下,并得到以下异常:

alter table test17 drop column [added column2];
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 '[added column2]' at line 1

alter table test17 drop column 'added column2';
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 ''added column2'' at line 1

alter table test17 drop column (added column2);
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 '(added column2)' at line 1

谢谢:)

最佳答案

您应该尝试使用反引号 ("`") 来引用您的列名。

ALTER TABLE test17 DROP COLUMN `added column2`;

没有COLUMN字

ALTER TABLE test17 DROP `added column2`;

关于mysql - 删除mysql中包含空格的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40501899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com