Home » Performance » MySQL » How can I create the database through query if the database name has blank spaces in it
How can I create the database through query if the database name has blank spaces in it [message #1962] Sat, 29 September 2007 01:16 Go to next message
kalyan_askc  is currently offline kalyan_askc
Messages: 3
Registered: September 2007
Location: India
Junior Member
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.


A.S.Kalyan
Re: How can I create the database through query if the database name has blank spaces in it [message #1970 is a reply to message #1962 ] Sun, 30 September 2007 18:25 Go to previous messageGo to next message
mikec  is currently offline mikec
Messages: 22
Registered: September 2007
Junior Member
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)
Re: How can I create the database through query if the database name has blank spaces in it [message #1971 is a reply to message #1962 ] Sun, 30 September 2007 20:05 Go to previous messageGo to next message
sterin  is currently offline sterin
Messages: 324
Registered: March 2007
Location: Sweden
Senior Member
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.
Re: How can I create the database through query if the database name has blank spaces in it [message #1973 is a reply to message #1970 ] Mon, 01 October 2007 00:26 Go to previous messageGo to next message
kalyan_askc  is currently offline kalyan_askc
Messages: 3
Registered: September 2007
Location: India
Junior Member
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,


A.S.Kalyan
Re: How can I create the database through query if the database name has blank spaces in it [message #1974 is a reply to message #1971 ] Mon, 01 October 2007 00:29 Go to previous messageGo to next message
kalyan_askc  is currently offline kalyan_askc
Messages: 3
Registered: September 2007
Location: India
Junior Member
Hi sterin,


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

Regards,


A.S.Kalyan
Re: How can I create the database through query if the database name has blank spaces in it [message #1975 is a reply to message #1962 ] Mon, 01 October 2007 00:44 Go to previous message
mikec  is currently offline mikec
Messages: 22
Registered: September 2007
Junior Member
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.
Previous Topic:prepared statements in MySQL
Next Topic:MYSQL Swapping Issue / Memory Usage
Goto Forum:
  


Current Time: Fri Jul 10 06:55:56 EDT 2009

Total time taken to generate the page: 0.01332 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.