4

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?

John
  • 3,238
  • 4
  • 22
  • 25
  • `for a real reason` Care to elaborate? – Your Common Sense Sep 10 '10 at 12:53
  • Col. Shrapnel: It's being GZipped, but I really did not want somebody suggesting or asking why I wanted this or that, when I knew what I was doing there. I guess you did what I didn't want anyway! – John Sep 10 '10 at 12:56

2 Answers2

7

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

Spudley
  • 166,037
  • 39
  • 233
  • 307
  • Confused myself, I assumed because it was variable length it didn't need a max at the moment, It is late, thanks. – John Sep 10 '10 at 12:55
4

You need to add size of varbinary:

VARBINARY( 100 )
cichy
  • 10,464
  • 4
  • 26
  • 36