Rename a MySQL column containing ` in the column name

469 Views Asked by At

So, the other guy at work created a table with a column called:

    Max(`abs_spg_20090430`.`ID`)

this is giving me an error now that I am trying to run a dump of the database on a different server.

I am trying to rename it, but

    ALTER TABLE abs_spgID_20090504 CHANGE Max(`abs_spg_20090430`.`ID`) id bigint default null;

as well as

    ALTER TABLE abs_spgID_20090504 CHANGE `Max(`abs_spg_20090430`.`ID`)` id bigint default null;

give me an error. Does any of you friendly people have a hint? Many thanks!

1

There are 1 best solutions below

2
On

you need to quote your quotes and the column too, e.g:

ALTER TABLE abs_spgID_20090504  CHANGE `Max(``abs_spg_20090430``.``ID``)` id BIGINT DEFAULT NULL;