I'm new to MySQL and I'm running version 5.7.19-log (At least thats what I'm getting from command line client) with Workbench 6.3.9 Community edition. My problem is I'm trying to create a simple table with auto-generated id using the UI, however when I execute the generated script it throws me the following error:
Operation failed: There was an error while applying the SQL script to the database.
Executing:
CREATE TABLE `travelportaldb`.`user` (
`user_id` INT GENERATED ALWAYS AS () VIRTUAL,
`name` VARCHAR(45) NOT NULL,
`account_id` VARCHAR(15) NULL,
`account_currency` CHAR(3) NULL,
`account_balance` DECIMAL NULL,
PRIMARY KEY (`user_id`));
ERROR 1064: 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 ') VIRTUAL,
`name` VARCHAR(45) NOT NULL,
`account_id` VARCHAR(15) NULL,
`ac' at line 2
SQL Statement:
CREATE TABLE `travelportaldb`.`user` (
`user_id` INT GENERATED ALWAYS AS () VIRTUAL,
`name` VARCHAR(45) NOT NULL,
`account_id` VARCHAR(15) NULL,
`account_currency` CHAR(3) NULL,
`account_balance` DECIMAL NULL,
PRIMARY KEY (`user_id`))
This is the script that it generated:
CREATE TABLE `travelportaldb`.`user` (
`user_id` INT GENERATED ALWAYS AS () VIRTUAL,
`name` VARCHAR(45) NOT NULL,
`account_id` VARCHAR(15) NULL,
`account_currency` CHAR(3) NULL,
`account_balance` DECIMAL NULL,
PRIMARY KEY (`user_id`));
I have no idea what's wrong. I'm from the oracle background and the query seems to be fine except the auto generated apart which I have no idea about.
Please help.
Thanks.


INT AUTO_INCREMENTINT GENERATED ALWAYS AS (expression)<- expects non-empty expression. See here about generated columns: dev.mysql.com/doc/refman/5.7/en/…