wiwa1978
wiwa1978

Reputation: 2707

SQL database with column in the tablename

I have an error in my MySQL statement (using shell file), which I can't seem to resolve. Tried to put quotes etc but no luck. When I created it using phpmyadmin it works, but I want to have it scripted. Must be something small... Any ideas?

--- Create mySQL database ---
CREATE DATABASE IF NOT EXISTS _test-123;
CREATE USER 'test-123'@localhost IDENTIFIED BY '***';
GRANT ALL PRIVILEGES ON _test-123.* TO 'test-123'@'localhost';
FLUSH PRIVILEGES;
Enter password:
ERROR 1064 (42000) at line 1: 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 '-123' at line 1

Upvotes: 0

Views: 31

Answers (1)

user5831063
user5831063

Reputation:

Try removing the "-" and do this one instead-

CREATE DATABASE IF NOT EXISTS _test_123;

Upvotes: 1

Related Questions