0

I would like to create a table with GENERATED as column in MySQL version 5.7.16. When I try below query it is giving error:

create table madhu (RECORDID VARCHAR(255) NOT NULL, GENERATED INTEGER NOT NULL);

Below is the error:

Error Code: 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 'GENERATED INTEGER NOT NULL)' at line 1 0.000 sec

It looks GENERATED is reserved key word. Is there away to have GENERATED as column? If I change the column it works anyway.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
Madhuprathap
  • 209
  • 1
  • 3
  • 15

1 Answers1

0

To escape reserved keywords use backticks or choose a different column name.

create table madhu
(
   RECORDID VARCHAR(255) NOT NULL, 
   `GENERATED` INTEGER NOT NULL
);
juergen d
  • 201,996
  • 37
  • 293
  • 362
  • I can't choose different name .. as these column name is generated. Is there any server level config to overwrite this behavior. May be some config in my.cnf ? – Madhuprathap Nov 16 '16 at 14:53
  • I doubt it since the query parser does not understand your query with a reserved word at the wrong place. – juergen d Nov 16 '16 at 15:16