ivange
ivange

Reputation: 464

error when using single quotes in mysql when creating a database

I want to create a database that has a dash in the name, like my-db. i have tried

create database 'my-db';

Below is the output from my terminal

mysql> CREATE DATABASE 'my-db'; 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 ''my-db'' at line 1

I have googled how to create such a database name and all links tell me to use single quotes around the name. But i don't know why its not working for me. How else can i create database with name that has a dash in it?

Upvotes: 1

Views: 2729

Answers (1)

newman
newman

Reputation: 2719

Try

create database `my-db`; 

or

create database my-db;

It must work.

For database you should use backticks or not use any symbols.

Upvotes: 1

Related Questions