MySQL 5.6.20 alter ignore 错误 table

MySQL 5.6.20 error in alter ignore table

我添加此行以将 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

如何修复此错误?谢谢。

语法问题

  1. alter ignore missing the table keyword
  2. syntax should only include the name within the unique index not after the tablename

调整后

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] ...