I am not able to figure out what's the problem here

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 ')' at line 9 SQL Statement:

CREATE TABLE `usersdb`.`users_details` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `username` VARCHAR(45) NOT NULL,
  `password` VARCHAR(45) NOT NULL,
  `email_address` VARCHAR(45) NOT NULL,
  `first_name` VARCHAR(45) NOT NULL,
  `last_name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE)

Upvotes: 1

Views: 292

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521053

MySQL indices are visible by default, and prior to MySQL 8+, the VISIBLE and INVISIBLE keywords are not supported. Assuming you are running 5.7 or earlier, try removing VISIBLE:

CREATE TABLE usersdb.users_details (
    id INT NOT NULL AUTO_INCREMENT,
    username VARCHAR(45) NOT NULL,
    password VARCHAR(45) NOT NULL,
    email_address VARCHAR(45) NOT NULL,
    first_name VARCHAR(45) NOT NULL,
    last_name VARCHAR(45) NOT NULL,
    PRIMARY KEY (id),
    UNIQUE INDEX id_UNIQUE (id)
);

Edit: I just realized from your error output that you are using MariaDB. The fix would be the same as above, but I am not sure at which exact version MariaDB rolled out invisible indices.

Upvotes: 4

Related Questions