Mysql 创建语法错误 table

Mysql Syntax error on creating table

我在 docker 容器中有一个 MySQL 数据库。 入口点执行创建数据库的脚本和创建 tables.

的脚本

除一个 table 外,一切正常。

use db;

... creating other tables

CREATE TABLE mediametadata
(
id bigint not null  primary key,
title VARCHAR not NULL,
artist VARCHAR not NULL,
album VARCHAR,
releaseYear bigint,
mediaId bigint NOT NULL,
constraint fk__pk_metadata_objectid
        foreign key (id) references objectid (id),

constraint fk__metadata_media_id
        foreign key (mediaId) references media (id)
)
;

记录到控制台的错误是

mysql_1  | ERROR 1064 (42000) at line 150: 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 'not NULL,
mysql_1  | artist VARCHAR not NULL,
mysql_1  | album VARCHAR,
mysql_1  | releaseYear bigint,
mysql_1  | mediaId bi' at line 4

第150行是CREATE TABLE mediametadata

之后的左括号

我开始认为 yearmetadata 可能是保留关键字,所以我重命名了 table 和 year 列,但错误仍然存​​在。

@Bill Karwin 在第一条评论中回答 Varchar 需要长度 [Varchar(number)]