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.
- mysql> CREATE DATABASE foo-bar;
- 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
- mysql> CREATE DATABASE `foo-bar`;
- mysql> DROP DATABASE `foo-bar`;
MySQL, programming
:tags
Comments (1)
Post a New Comment
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.
- Tags
- AI (1)
- ALIX (1)
- digitalfoo.net (2)
- embedded (6)
- FreeBSD (30)
- Java (1)
- Linux (26)
- misc (7)
- my projects (1)
- MySQL (2)
- NanoBSD (3)
- opensource (7)
- perl (1)
- PHP (3)
- programming (11)
- Python (1)
- security (4)
- Archives
- 2011
- February (1)
- March (1)
- June (1)
- July (1)
- August (1)
- 2010
- June (5)
- July (2)
- December (4)
- April (6)
- March (2)
- May (1)
- August (2)
- October (1)
- November (1)
- 2009
- August (7)
- July (8)
- April (4)
- May (4)
- December (2)
- June (1)
- September (1)
- November (4)
- October (1)
- Web Tools
- Index
- dig-shovel Live
- SQL Injection Encoder
- Links
-

