gpt4 book ai didi

Mysql创建表时语法错误

转载 作者:行者123 更新时间:2023-11-29 02:12:28 25 4
gpt4 key购买 nike

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

除了一张 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之后的左括号

  • MySQL版本:8.0.3-rc-log
  • 主机操作系统:Debian jessie

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

最佳答案

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

关于Mysql创建表时语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48099678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com