alter ignore table中的MySQL 5.6.20错误

时间:2015-09-07 12:13:08

标签: mysql mysql-5.6

我添加此行以添加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 个答案:

答案 0 :(得分:1)

语法问题

  
      
  1. alter ignore缺少表关键字
  2.   
  3. 语法应仅包含唯一索引中的名称,而不是在tablename
  4. 之后   

<强>调节

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