mysql - problem with create another table with relation

35 views Asked by At

When I want in tableplus create another table with relation to table 'users', I get error:

Query 1 ERROR: 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 'VISIBLE,
  CONSTRAINT `uid`
    FOREIGN KEY (`uid`)
    REFERENCES `users` (`id`' at line 9

Bellow my query:

CREATE TABLE `posts` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `title` VARCHAR(255) NOT NULL,
  `desc` VARCHAR(1000) NOT NULL,
  `img` VARCHAR(255) NOT NULL,
  `date` VARCHAR(255) NOT NULL,
  `uid` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `uid_idx` (`uid` ASC) VISIBLE,
  CONSTRAINT `uid`
    FOREIGN KEY (`uid`)
    REFERENCES `users` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
);
1

There are 1 answers

0
mxcdh On

edit: -VISIBLE/INVISIBLE isn't supported until MySQL 8.0.23. You must be on an older version. -it's failing on the keyword VISIBLE, just remove that