英文:
Can anyone find the error in this MySQL code? (beginner)
问题
Here's the translated SQL code without the error messages:
CREATE TABLE `students`.`studentinfo` (
id int,
name varchar,
age int
) ENGINE = InnoDB
COMMENT = 'test';
And the modified code without columns:
CREATE TABLE `students`.`studentinfo` (
) ENGINE = InnoDB
COMMENT = 'test';
英文:
CREATE TABLE `students`.`studentinfo` (
id int,
name varchar,
age int
);
ENGINE = InnoDB
COMMENT = 'test';
I am using the MySQL Workbench and I am trying to create a table named students. However my code gives the error message
Operation failed: There was an error while applying the SQL script to the database.
Executing:
CREATE TABLE `students`.`studentinfo` (
id int,
name varchar,
age int
);
ENGINE = InnoDB
COMMENT = 'test';
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 ',
age int
)' at line 3
SQL Statement:
CREATE TABLE `students`.`studentinfo` (
id int,
name varchar,
age int
)
I tried to solve this by removing the table like so:
CREATE TABLE `students`.`studentinfo` (
)
ENGINE = InnoDB
COMMENT = 'test';
and even then it still doesn't work! It gives the same error message:
Operation failed: There was an error while applying the SQL script to the database.
Executing:
CREATE TABLE `students`.`studentinfo` (
)
ENGINE = InnoDB
COMMENT = 'test';
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 ')
ENGINE = InnoDB
COMMENT = 'test'' at line 2
SQL Statement:
CREATE TABLE `students`.`studentinfo` (
)
ENGINE = InnoDB
COMMENT = 'test'
答案1
得分: 1
varchar
需要指定长度:
创建表格 students
.studentinfo
(
id 整数,
name 变长字符(100),
age 整数
)
英文:
varchar
needs a length:
CREATE TABLE `students`.`studentinfo` (
id int,
name varchar(100),
age int
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论