Home > OS >  Cannot create table in MYSQL with UNICODE and INTEGER types, ERROR: 1064
Cannot create table in MYSQL with UNICODE and INTEGER types, ERROR: 1064

Time:12-04

I am trying to create a simple table in mysql but I am getting a syntax error.

Here is the code:

CREATE TABLE survey(
    id INTEGER(15)  NOT NULL,
    `name` UNICODE(65) NOT NULL,
    parentId INTEGER(15)  NOT NULL, 
    createdAt TIMESTAMP(30) NOT NULL, 
    modifiedAt TIMESTAMP (30) NOT NULL, 
    surveyUrl UNICODE(100) NOT NULL,
    PRIMARY KEY(id)
);

I have tried changing the UNICODE to STRING and placing the column names between marks with no luck. Thank you!

CodePudding user response:

a Datatype UNICOde and the prcision 30 for timestampo are not allowed.

You can switch to following format, iff you need another character set and collation besides the default

More about collations

CREATE TABLE survey(
    id BIGINT  NOT NULL,
    `name` varchar(65) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
    parentId BIGINT  NOT NULL, 
    createdAt TIMESTAMP(6) NOT NULL, 
    modifiedAt TIMESTAMP (6) NOT NULL, 
    surveyUrl varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
    PRIMARY KEY(id)
);
  • Related