Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: Cannot create table with VARBINARY?

I am running this query to set up a VARBINARY (I wish for it to be so, for a real reason) field for my database:

CREATE TABLE `test_books` (`id` int UNSIGNED NOT NULL,`book` VARBINARY, `timestamp` int(11) NOT NULL, UNIQUE KEY `id` (`id`))

It hands me a standard syntax error telling me to check all the remaining code after 'VARBINARY'.

My MySQL server version is 5.0.87.d10, which is claimed to support the datatype since 5.0.

I changed VARBINARY directly into int and the query worked fine, could there be something I left out after it?

like image 413
John Avatar asked Dec 29 '22 07:12

John


1 Answers

You need to specify a length for [var]binary fields, just as you do for char/varchar.

like image 173
Spudley Avatar answered Dec 30 '22 21:12

Spudley