Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL - CREATE DATABASE Syntax

Status
Not open for further replies.

langron

Technical User
Dec 19, 2003
1
US
I'm having a little trouble with what I thought would be an easy task. I want to create a database with a two-word name. But my Execute command is failing even though I've tried many syntax combinations of ', '', (),[], etc to enclose a two-word name.

For example, I can do this:
SQL = "CREATE DATABASE oneword"
MyConnection.Execute SQL

But my Execute command fails with any one of these:
SQL = "CREATE DATABASE two words"
SQL = "CREATE DATABASE (two words)"
SQL = "CREATE DATABASE [two words]"
SQL = "CREATE DATABASE 'two words'"

Can someone please help me with the syntax?

Thanks in advance - Ron
 
Using a multiword database name is a bad idea. It can cause problems with software that tries to manipulate data in that database.

If you feel you simply must use a multiword name for a database, surround the database name with backticks (on a US keyboard, the backtick is on the same key as the tilde):

create database `foo bar`

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top