Home > Net >  What is wrong with my SQL Statement when creating a table
What is wrong with my SQL Statement when creating a table

Time:07-06

whats wrong with this code?

CREATE TABLE `cars` (
    `id` INT unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `name` varchar,
    `image` varchar
    ) ENGINE = INNODB DEFAULT CHARSET = utf8;

Err:

#1064 - Near '
    `image` varchar
    ) ENGINE = INNODB DEFAULT CHARSET = utf8' in Zeile 3

Can anyone help me to solve this issue ?

CodePudding user response:

varchar must have a size, when you define it.

So you can choose for example 100

CREATE TABLE `cars` (
    `id` INT unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `name` varchar(100),
    `image` varchar(100)
    ) ENGINE = INNODB DEFAULT CHARSET = utf8;
  • Related