【问题标题】:MySQL 5.6.20 error in alter ignore table更改忽略表中的 MySQL 5.6.20 错误
【发布时间】:2015-09-07 12:13:07
【问题描述】:

我添加此行以将 ignore 添加到 MySql 数据库:

ALTER IGNORE cms_books_author name ADD UNIQUE(name)

但我收到此错误:

Error
SQL query:


ALTER IGNORE cms_books_author name ADD UNIQUE(name)
MySQL said: Documentation

#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 'efcms_books_author name ADD UNIQUE(name)' at line 1 

Mysql版本为:5.6.20

如何解决这个错误?谢谢。

【问题讨论】:

  • 缺表并调整唯一索引的语法:ALTER IGNORE table cms_books_author ADD UNIQUE(name);
  • @amdixon:你说得对。为您添加接受的答案。

标签: mysql mysql-5.6


【解决方案1】:

语法问题

  1. alter ignore 缺少 table 关键字
  2. 语法应该只包括唯一索引中的名称,而不是表名之后

调整

ALTER IGNORE table cms_books_author ADD UNIQUE(name);

sqlfiddle


alter table syntax

ALTER [ONLINE | OFFLINE] [IGNORE] TABLE tbl_name
    [alter_specification [, alter_specification] ...]
    [partition_options]

...

alter_specification:
    table_options
  | ADD [CONSTRAINT [symbol]]
        UNIQUE [INDEX|KEY] [index_name]
        [index_type] (index_col_name,...) [index_option] ...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-23
    • 2012-07-01
    • 2017-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    相关资源
    最近更新 更多