我正在使用MySQL工作台创建</panel></row><row><panel>
,并且产生的index
语句是:
create
但这给了我错误:
CREATE TABLE IF NOT EXISTS `test`.`location` (
`location_id` INT UNSIGNED NOT NULL,
`name` VARCHAR(255) NOT NULL,
PRIMARY KEY (`location_id`),
FULLTEXT INDEX `name_fulltext` USING BTREE (`name` ASC))
ENGINE = InnoDB;
如果我将Executing SQL script in server
ERROR: Error 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 'USING BTREE (`name` ASC))
ENGINE = InnoDB' at line 8
SQL Code:
-- -----------------------------------------------------
-- Table `ofloy`.`location`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ofloy`.`location` (
`location_id` INT UNSIGNED NOT NULL,
`name` VARCHAR(255) NOT NULL,
PRIMARY KEY (`location_id`),
FULLTEXT INDEX `name_fulltext` USING BTREE (`name` ASC))
ENGINE = InnoDB
的索引更改为:FULLTEXT
,则一切正常。 https://dev.mysql.com/doc/refman/8.0/en/fulltext-natural-language.html
但是为什么工作台会创建错误的语法?我检查了Model正在使用的mysql版本(从Model> Model options> MySQL),这是我的服务器默认FULLTEXT (name)
。
工作台版本:8.0.12
答案 0 :(得分:2)
删除索引类型USING BTREE
对于全文索引来说是错误的语法类型。
BTREE是一种索引类型:
index_type
USING {BTREE | HASH}
index_type用于普通索引
{INDEX|KEY} [index_name] [index_type] (key_part,...)
[index_option] ...
FULLTEXT INDEX的正确语法如下:
{FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (key_part,...)
[index_option] ...
https://dev.mysql.com/doc/refman/8.0/en/create-table.html#create-table-indexes-keys
在以下查询中运行:
CREATE TABLE IF NOT EXISTS `test`.`location` (
`location_id` INT UNSIGNED NOT NULL,
`name` VARCHAR(255) NOT NULL,
PRIMARY KEY (`location_id`),
FULLTEXT INDEX `name_fulltext`(`name`)
) ENGINE = InnoDB;