我正在尝试在Workbench中转发工程师ER图以创建我的架构,但是出现错误。我正在为Mac使用mySql Workbench。
这是我收到的错误消息:
Executing SQL script in server
ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
INDEX `city_id_fk_idx` (`city_id` ASC) VISIBLE,
INDEX `county_id_idx` (`cou' at line 13
SQL Code:
-- -----------------------------------------------------
-- Table `k00243666_property_bubble`.`addresses`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `k00243666_property_bubble`.`addresses` (
`address_id` INT NOT NULL AUTO_INCREMENT,
`address1` VARCHAR(45) NULL,
`address2` VARCHAR(45) NULL,
`eircode` VARCHAR(7) NULL,
`town_id` INT NULL,
`city_id` INT NULL,
`county_id` INT NULL,
PRIMARY KEY (`address_id`),
INDEX `town_id_fk_idx` (`town_id` ASC) VISIBLE,
INDEX `city_id_fk_idx` (`city_id` ASC) VISIBLE,
INDEX `county_id_idx` (`county_id` ASC) VISIBLE,
CONSTRAINT `town_id_fk`
FOREIGN KEY (`town_id`)
REFERENCES `k00243666_property_bubble`.`town` (`town_id`)
ON DELETE NO ACTION
ON UPDATE CASCADE,
CONSTRAINT `city_id_fk`
FOREIGN KEY (`city_id`)
REFERENCES `k00243666_property_bubble`.`city` (`city_id`)
ON DELETE NO ACTION
ON UPDATE CASCADE,
CONSTRAINT `county_id`
FOREIGN KEY (`county_id`)
REFERENCES `k00243666_property_bubble`.`county` (`county_id`)
ON DELETE NO ACTION
ON UPDATE CASCADE)
ENGINE = InnoDB
SQL script execution finished: statements: 5 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
有人知道我为什么收到此错误吗?
答案 0 :(得分:0)
我的猜测是,您的MariaDB版本不支持VISIBLE
或INVISIBLE
应用于索引定义。无论如何,默认情况下索引应该是可见的,因此甚至不需要指定VISIBLE
。尝试使用以下语法:
INDEX town_id_fk_idx (town_id),
INDEX city_id_fk_idx (city_id),
INDEX county_id_idx (county_id)
Here is a link到对MariaDB提出的功能请求。 INVISIBLE
语法似乎没有关闭优化器的索引。但是,它提供了一种替代方法:
ALTER TABLE addresses DISABLE KEYS;
这将使优化器看不到所有索引。