gpt4 book ai didi

MySQL 5.6.20 alter ignore table 错误

转载 作者:行者123 更新时间:2023-11-29 02:54:17 28 4
gpt4 key购买 nike

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

关于MySQL 5.6.20 alter ignore table 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32438485/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com