Punch MySQL in the Face For Me

All technology has some teething problems, all has its quirks but right now the focus of my ire is MySQL and the myriad of ways it has to frustrate you.

1. Hyphens are valid in Database names but Mysql5 has a bug that means they don’t work

Sure you can use mysqladmin to create a database such as ‘my-awesome-db’ but mysql will not be able to do much with it (even if you quote it) such as trying to drop it or grant new permissions. You will spend endless hours trying to debug scripts before realising that it really isn’t you.

Technically you should be able to use the back-tick ` to escape the name, but this was a path to banging your head on the table, rather than solving anything.

So if you can, avoid hyphens in database names.

For more see:

http://stackoverflow.com/questions/2030364/prevent-user-from-creating-tables-and-or-databases-with-hyphen

http://stackoverflow.com/questions/3168644/can-a-table-field-contain-a-hyphen

Space between a function name and its parameter list results in hard to see bugs

Apparently MySQL doesn’t like spaces between a function name and its parameter list.

Its ok to write Concat(param, param) but not Concat (param, param).

I was trying to track down what was wrong in a script which just happened to word wrap on the space. Wasted a fair amount of time with that one, especially as the space was in the middle of a fairly long command.

Every other language I work with doesn’t care about whitespace, the whitespace is just there to make things readable.

  1. Theres actually a really good list of gotchas here:
    http://sql-info.de/mysql/gotchas.html

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>