Search code examples
mysqlmysql-workbenchmysql-error-1064

#1064, xammp, phpMyAdmin, MYSQL - Why have I an error in mySQL syntax?


#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 ') VIRTUAL,
  `title_type` VARCHAR(45) NULL DEFAULT null,
  PRIMARY KEY (`id`))' at line 2

Here is a part of script:

CREATE TABLE IF NOT EXISTS `sggis`.`maps_type` (
  `id` INT GENERATED ALWAYS AS () VIRTUAL,
  `title_type` VARCHAR(45) NULL DEFAULT 'yandex',
  PRIMARY KEY (`id`)) 
ENGINE = InnoDB;

SQL says that problem is in the 2nd line, but i can't find it. Code generated by MySQL Workbench.


Solution

  • When using VIRTUAL columns you need to specify the expression

    Any legal, deterministic expression which can be calculated is permitted, with the following exceptions:

    Your expression is blank.