the Little Projects of Shawn M. Jones » » databases /blog the life and times of a man in 21st Century America Sat, 06 Dec 2014 18:06:07 +0000 en-US hourly 1 http://wordpress.org/?v=4.3.1 Spaces in MySQL Table Names /blog/2007/07/12/spaces-in-mysql-table-names/ /blog/2007/07/12/spaces-in-mysql-table-names/#comments Thu, 12 Jul 2007 04:37:00 +0000 http://wwwnew.littleprojects.org/?p=12
Print Friendly

I’ve been playing with databases a bit lately for a small file tagging project I’m working on at home. My muse has inspired me to investigate cataloging methods and my files seemed to be a good start. More updates on this as it continues to grow.

Many of you probably know this, but I couldn’t seem to find it on the Net. I was probably searching on the wrong thing, but wanted to make sure I helped out all of the other MySQL users out there.

I created some tables using the gui from OpenOffice.org Base and put spaces into the table names. Surprising to me, it was ok with the spaces. When I tried using the mysql command line client later, I found that I couldn’t figure out how to reference them.

Yes, Virginia, you can have spaces in your database table names. This is how you referenced them:

SELECT * FROM `My Table`

Those special characters there are not apostrophes (‘), but backticks (`). Slight difference. The symbol is on the same key as the tilde (~) on your keyboard.

In theory the ` should also work for fields with spaces in them too.

Supposedly Microsoft SQL Server uses brackets ([]) to handle tables and fields with spaces in them, but MySQL does not seem to follow this convention. I hadn’t checked Oracle, Sybase, or PostgreSQL.

And, now I’ve been bad and stayed up too late again. G’night folks!

]]>
/blog/2007/07/12/spaces-in-mysql-table-names/feed/ 0