Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 我能';由于语法错误,无法创建SQL表_Mysql_Database_Mysql Workbench - Fatal编程技术网

Mysql 我能';由于语法错误,无法创建SQL表

Mysql 我能';由于语法错误,无法创建SQL表,mysql,database,mysql-workbench,Mysql,Database,Mysql Workbench,我尝试在本地SQL数据库中创建一个表。我遵循了一个教程,最后出现了一个语法错误。我检查了几个类似的stackoverflow线程,解决方案是删除保留字……但在我的代码中,我也找不到保留字 我的代码中的问题在哪里 create table teams ( team_id int(11) not null PRIMARY KEY AUTO_INCREMENT, name varchar() not null, logo varchar() not null, foun

我尝试在本地SQL数据库中创建一个表。我遵循了一个教程,最后出现了一个语法错误。我检查了几个类似的stackoverflow线程,解决方案是删除保留字……但在我的代码中,我也找不到保留字

我的代码中的问题在哪里

create table teams (
    team_id int(11) not null PRIMARY KEY AUTO_INCREMENT,
    name varchar() not null,
    logo varchar() not null,
    founded int(4) not null,
    venue_capacity int(6) not null,
    squad_value int(5) not null,
    total_national_trophies int(3) not null
); 
错误消息:

#1064 - Fehler in der SQL-Syntax. Bitte die korrekte Syntax im Handbuch nachschlagen bei ') not null,
    logo varchar() not null,
    founded int(4) not null,
    ven' in Zeile 3

您需要为
VARCHAR
列指定大小,例如
VARCHAR(255)

大小表示可以插入到列中的最大字符数(不是字节)

重写的语句可能如下所示:

CREATE TABLE teams (
    team_id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    name VARCHAR(255) NOT NULL,
    logo VARCHAR(255) NOT NULL,
    founded INT(4) NOT NULL,
    venue_capacity INT(6) NOT NULL,
    squad_value INT(5) NOT NULL,
    total_national_trophies INT(3) NOT NULL
); 


*我更喜欢使用大写的SQL关键字。这只是一个偏好的问题,在执行上绝对没有区别。

您的查询应该是:

create table teams (
    team_id int(11) not null PRIMARY KEY AUTO_INCREMENT,
    name varchar(255) not null,
    logo varchar(255) not null,
    founded int(4) not null,
    venue_capacity int(6) not null,
    squad_value int(5) not null,
    total_national_trophies int(3) not null
)

added varchar(255)

…谢谢,成功了。我们将尽快接受答复。祝您有个美好的一天。