【问题标题】:I can't rename a mysql table name... it has a space in it我无法重命名 mysql 表名......它有一个空格
【发布时间】:2016-11-19 15:14:34
【问题描述】:

我已将 csv 导入 MySQL。 PHPMyAdmin 帮助创建了一个名为 TABLE 8 的表(带有空格)。

当我尝试在 SQL 中重命名时:

RENAME TABLE 8 to gender

我得到错误:

#1064 - 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 '`TABLE 8` to `gender`' at line 1

我已经尝试过反引号、引号……似乎一切……

我猜是空间造成了问题,但我没有想法。

【问题讨论】:

  • table 8 的名称是什么? Rename table 'table 8' to 'gender' 其中刻度是反引号
  • 是的,表 8 @xQbert
  • 谢谢@xQbert - 明白了。干杯。 :-)
  • @stilts77 所有的程序员都会犯错误,有时是非常简单的错误!

标签: mysql sql syntax-error ddl table-rename


【解决方案1】:

语法错误,您缺少 table 关键字(是的,请注意 `s 以转义包含空格的表名):

RENAME TABLE `TABLE 8` TO gender

或者,您可以使用更完整的语法:

ALTER TABLE `TABLE 8` RENAME TO gender

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-31
    • 2015-07-26
    • 1970-01-01
    • 2011-05-30
    相关资源
    最近更新 更多