2015-09-07 36 views
2

我加入這行添加ignore MySQL數據庫:的MySQL 5.6.20錯誤ALTER忽略表

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表cms_books_author ADD UNIQUE(name);' – amdixon

+0

@amdixon:你說得對。爲你接受接受答案。 – Perspolis

回答

1

語法問題

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