# How can I create the database through query if the database name has blank spaces in it

**URL:** <https://forums.percona.com/t/how-can-i-create-the-database-through-query-if-the-database-name-has-blank-spaces-in-it/472>\
**Category:** Other MySQL® Questions\
**Created:** [September 28, 2007, 11:46pm UTC](https://forums.percona.com/t/how-can-i-create-the-database-through-query-if-the-database-name-has-blank-spaces-in-it/472 "2007-09-28T23:46:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kalyan\_askc](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@kalyan\_askc](https://forums.percona.com/u/kalyan_askc)\
**Post date:** [September 28, 2007, 11:46pm UTC](https://forums.percona.com/t/how-can-i-create-the-database-through-query-if-the-database-name-has-blank-spaces-in-it/472/1 "2007-09-28T23:46:52Z")

</div>

Hi All,

I am new to MySQL. I am using SQLYOG for database manipulations. I have a doubt regarding creation of database. When I tried to create a database “a b c” through the following query " create database ‘a b c’ " , I got an error message. But by clicking on the ‘DB’ menu in the menubar and selecting ‘create database’ menuitem, I am able to create the database ‘a b c’.

Kindly let me know How can I create the database through query if the database name has blank spaces in it?

Regards,  
A.S.Kalyan.

---

<div class="post-metadata">

**Author:** ![mikec](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@mikec](https://forums.percona.com/u/mikec)\
**Post date:** [September 30, 2007, 4:55pm UTC](https://forums.percona.com/t/how-can-i-create-the-database-through-query-if-the-database-name-has-blank-spaces-in-it/472/2 "2007-09-30T16:55:39Z")

</div>

o:my\> set sql\_quote\_show\_create=1;  
Query OK, 0 rows affected (0.00 sec)

o:my\> create database `a b c`;  
Query OK, 1 row affected (0.00 sec)

o:my\> show databases like ‘a%’;  
±--------------+  
| Database (a%) |  
±--------------+  
| a b c |  
±--------------+  
1 row in set (0.01 sec)

o:my\> drop database `a b c`;  
Query OK, 0 rows affected (0.00 sec)

---

<div class="post-metadata">

**Author:** ![sterin](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sterin](https://forums.percona.com/u/sterin)\
**Post date:** [September 30, 2007, 6:35pm UTC](https://forums.percona.com/t/how-can-i-create-the-database-through-query-if-the-database-name-has-blank-spaces-in-it/472/3 "2007-09-30T18:35:51Z")

</div>

Although it is possible to use backticks in MySQL to create all kinds of strange database/table/column names.

I strongly recommend against it. It’s just asking for trouble.  
For example, are you happier with a database name with spaces in it? You have already realized that there are problems with it.  
If you want to separate a name consisting of several words use underscore or an uppercase letter instead (note however that mysql on windows is not case sensitive on database/table names since windows hasn’t a case sensitive filesystem.

---

<div class="post-metadata">

**Author:** ![kalyan\_askc](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@kalyan\_askc](https://forums.percona.com/u/kalyan_askc)\
**Post date:** [September 30, 2007, 10:56pm UTC](https://forums.percona.com/t/how-can-i-create-the-database-through-query-if-the-database-name-has-blank-spaces-in-it/472/4 "2007-09-30T22:56:38Z")

</div>

Hi Mike…

Glad to have some useful help here by you. I tried to follow your instructions. Though the statement “set sql\_quote\_show\_create=1;” has worked fine but the statement for creating the database didn’t. It has shown 1064 error, asking to check the manual. Can u pls send some other way to handle the problem?  
I am facing some other problem too. As I have created some other databases from the GUI I developed in Java, they are not being updated concurrently. If u have an idea abt java, here is the code that I used to create the statement.

Statement stmt = con.createStatement(ResultSet.TYPE\_SCROLL\_SENSITIVE,ResultSe t.CONCUR\_UPDATABLE);

‘con’ is the connection to the mysql database here. If u can help me in some way, I’ld be thankful.

Regards,

---

<div class="post-metadata">

**Author:** ![kalyan\_askc](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@kalyan\_askc](https://forums.percona.com/u/kalyan_askc)\
**Post date:** [September 30, 2007, 10:59pm UTC](https://forums.percona.com/t/how-can-i-create-the-database-through-query-if-the-database-name-has-blank-spaces-in-it/472/5 "2007-09-30T22:59:39Z")

</div>

Hi sterin,

Thank u for that suggestion but we have a task to create such databases too.

Regards,

---

<div class="post-metadata">

**Author:** ![mikec](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@mikec](https://forums.percona.com/u/mikec)\
**Post date:** [September 30, 2007, 11:14pm UTC](https://forums.percona.com/t/how-can-i-create-the-database-through-query-if-the-database-name-has-blank-spaces-in-it/472/6 "2007-09-30T23:14:04Z")

</div>

Hi,

Not enough info to go on - get rid of the semicolon?

p.s.

I agree that spaces, caps, etc… are a really bad  
idea for names of tables/columns, etc… you will pay  
for it somewhere down the road.
