mysqlimport - issue with spaces in table name

922 views Asked by At

Dealing with some seriously incompetent database design here. Moving an app from MS Access to mySQL and for the moment it is important to preserve table names. However the Access db creator has spaces in his table names...

I tried doing this import with soft quotes, hard quotes, backticks, and no quotes but all give

    "check the manual that corresponds to your MySQL server version for the right
    syntax to use near 'Citation Table' at line 1, 
    when using table: Chain Citation Table"

I saw that you can escape spaces in some commands eg rm Chain\ Citation\ Table.txt but I get the same error from that.

Here is an example:

mysqlimport --host=mysql.myhost.com --user=dbuser -p \
--local --delete \
--fields-optionally-enclosed-by='|'   \
--fields-terminated-by=';' \
--lines-terminated-by='\n'   \
dbname "Chain Citation Table.txt"

What is the right way to handle this messed up situation? Do I have to make a holding table named SomethingWithoutSpaces and import to it and then copy across?

Thanks for any advice.

2

There are 2 answers

0
jerrygarciuh On BEST ANSWER

In the end my solution is to split the massive delimited file into parts and import via phpMyAdmin. If anyone knows a way to specify a table name with spaces in it for mysqlimport syntax I would appreciate their help!

// 4.19.2011 Update

Found a better way using SQL, duh.

TRUNCATE TABLE `Chain Citation Table`;
LOAD DATA LOCAL  INFILE ' Chain Citation Table.txt' INTO TABLE `Chain Citation Table`;
3
Kyle On

You could try using this Access to MySQL converter , it has worked well for me in the past.