0

I am using workbench for class and have to run this query and keep getting this:

Error Code: 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 ' CONSTRAINT fk_artwork_artist FOREIGN KEY (artist_id) REFERENCE...' at line 10

I am using version 10.4.21 and i can't find anything about what the syntax is suppose to be other than what I already have. Below is the query.

    CREATE TABLE IF NOT EXISTS `art_gallery`.`artwork` (
      `artwork_id` INT NOT NULL AUTO_INCREMENT,
      `title` VARCHAR(50) NOT NULL,
      `artyear` INT(4) NOT NULL,
      `period` VARCHAR(25) NULL,
      `arttype` VARCHAR(20) NULL,
      `artfile` VARCHAR(25) NOT NULL,
      `artist_id` INT NOT NULL,
      PRIMARY KEY (`artwork_id`),
      INDEX `fk_artwork_artist_idx` (`artist_id` ASC) VISIBLE,
      CONSTRAINT `fk_artwork_artist`
        FOREIGN KEY (`artist_id`)
        REFERENCES `art_gallery`.`artist` (`artist_id`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION)
    ENGINE = InnoDB;
Ken White
  • 123,280
  • 14
  • 225
  • 444

1 Answers1

0

VISIBLE keyword on the index was added in MariaDB-10.5.3 MDEV-22199. You appear to be using an earlier version.

To correct, you can just omit VISIBLE.

ref: 10.4 fiddle example

danblack
  • 12,130
  • 2
  • 22
  • 41