I have a MySQL database inside a docker container. The entrypoint executes a script creating the database and a script creating tables.
Everything works fine except for one 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)
)
;
The error logged to console is
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
line 150 is the open bracket after CREATE TABLE mediametadata
- MySQL version: 8.0.3-rc-log
- Host OS: Debian jessie
I came to think year and metadata might be reserved keywords so I renamed the table and the year column but the error persists.
PRIMARY. Try it:create table foo ( id int, constraint mypk primary key (id));followed byshow create table fooand you won't see "mypk" anywhere.