创建表时出现Mysql语法错误

时间:2018-01-04 16:36:52

标签: mysql sql create-table mysql-8.0

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

除了一张桌子外,一切正常。

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

之后的空心括号
  • MySQL版本:8.0.3-rc-log
  • 主持人操作系统:Debian jessie

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

1 个答案:

答案 0 :(得分:2)

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

相关问题