Dealing with Dashes in MySQL Database Names
  Jul 17, 2011

I keep running across this problem and lots of people saying it simply can't be done (because they try to escape the dash or various other tricks that you would think would work simply don't...). The solution is simple: surround the database name with backticks. Use SHIFT and ~ to create the backtick symbol.

Now you should be able to use the database name how ever you would like.

  1. mysql> CREATE DATABASE foo-bar;
  2. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bar' at line 1
  3. mysql> CREATE DATABASE `foo-bar`;
  4. mysql> DROP DATABASE `foo-bar`;



Post a New Comment

Name

Message

Security
Code

        (case insensitive & space between words)


Posted Comments
anonymous  Aug 20, 2011
Set your own life easier get the <a href="http://bestfinance-blog.com/topics/credit-loans">credit loans</a> and all you want.