Sql script error on varchar and exit mysql

This sql script gives me an error in VARCHARand EXIT;. I am trying to run it under the MySQL console. Can I find out how to solve this?

CREATE TABLE Solution (
SolutionKey    INT NOT NULL, /* PRIMARY KEY (SolutionKey), */
FeatureKey    VARCHAR(100),    /* +++ Foreign key missing here */
Value    VARCHAR(4000)
);


CREATE TABLE InactiveContext (
CaseKey    INT NOT NULL,     /* PRIMARY KEY (CaseKey), */
Context    VARCHAR(100)
);

CREATE TABLE Class (
FeatureKey    VARCHAR(100),   /* +++ Foreign key missing here */
ClassName    VARCHAR(1000)
);


CREATE TABLE ExtraData (
Key    VARCHAR(1000),
Value    VARCHAR(1000),
FeatureKey   VARCHAR(100)    /* +++ Foreign key missing here */
);


CREATE TABLE ProblemCCBRFeatureSpec (
FeatureKey    VARCHAR(100),    /* +++ Foreign key missing here */
Question    VARCHAR(1000)
);


CREATE TABLE HashMap (
CollectionID    INT,       /* +++ Foreign key missing here */
Key    VARCHAR(1000),
Value    VARCHAR(1000)
);


CREATE TABLE HashSet (
CollectionID    INT,       /* +++ Foreign key missing here */
Value    VARCHAR(1000)
);


CREATE TABLE Constants (
ConstantName    VARCHAR(1000),    /* +++ Must be a primary key ??? */
ConstantValue    VARCHAR(4000)
);

COMMIT;
EXIT;
+3
source share
2 answers

VALUEand KEYare MySQL reserved words that you use as column names.

To fix this, you can either choose different names for these fields, or stick them in the reverse tick ( ` ) every time you use them in the query.

CREATE TABLE ExtraData (
`Key`    VARCHAR(1000),
`Value`    VARCHAR(1000),
FeatureKey   VARCHAR(100)  
);

Later, when you want to extract data from a table, you will have to use quotes again:

SELECT `Key`, `Value` from ExtraData;
+1
source

, ,

,

    CREATE TABLE ExtraData (Key    VARCHAR(1000),Value  
  VARCHAR(1000),FeatureKey   VARCHAR(100)  
  /* +++ Foreign key missing here */);
+1

Source: https://habr.com/ru/post/1770848/


All Articles