WakeArray WakeArray - 1 year ago 77
MySQL Question

Answered: Rename an event in MySQL that has a space in the name

I'm still kind of new to MySQL as I've only used the most basic functions and I've only been getting more overwhelmed as I get into the more impressive sides of it. I decided to make a scheduler event and I screwed up. I put a space in the name. I've tried renaming it, but it doesn't seem to be able to read it.

ALTER EVENT 'update bills'
RENAME TO 'update_bills';

I wouldn't be surprised if this was due to naming it update. In any case I'm just hoping I don't have to delete the database and start over. I'm on a 1and1.com unlimited server, so the closest I can get to my database is phpMyAdmin and it just glitches out when I try to do something through the API and gives me a syntax error when I use the SQL command above.

If I have to start over, so be it, but if there's a way to rename this thing without destroying my day's worth of work, I'd be forever grateful.

Answer: I was using single quotes instead of the backquote (aka backtick, aka grave accent, aka this guy: ` ) character as e4c5 and reds pointed out in the comments and answer below. I didn't know there was a functional difference till now.

Answer Source

Do it like this way:

Alter EVENT `update bills`  Rename To update_bills;

This char `` mysql need in any case to make your query construction DB Readable.

This is 100% working, Hope it helps

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download