Click to See Complete Forum and Search --> : Text format for MySQL LOAD


Ahimsa
07-27-2002, 08:50 AM
I am writing a text file to populate a MySQL database with the LOAD command.
Some of the fields have several words (e.g. titles of books): Do I "_" between words, or can I leave one white space between words as in "Cat in the Hat"? I can't track this info down in the html manual.
I do already know that a tab will shift the text to load into the next field.
Thanks

toolshed
07-30-2002, 08:17 PM
how did u get the load command to work in mysql. i am having a heck of time figuring it out. I can seem to get it to work.

Ahimsa
07-31-2002, 04:54 AM
Hey Toolshed#7

Welcome fellow Tool-head :D :D

Actually I found it pretty straightforward - I'm still battling with the privileges!!!
I used gEdit and wrote out my intended columns and rows, separating the columns with tabs (and for the record, it doesn't seem to matter whether a column contains white space or not, but it DOES matter to use tab space to spearate the columns!!)

Once you have set up the file to load, and created the relevant table with its use permissions then just type in at the mysql> prompt the following:
"load data local file {whateverthefile.txt} into table {thenameofthetable};
and hey presto!! you have a populated table. Only do it once though, otherwise it will just duplicate the info again as if it were new info.
Hope this helps.
Also, if you make any startling discoveries about mysql please post me off list 'cos I'm trying to get a handle on it from the manual and I'm not sure that I'm understanding all that is involved.

toolshed
08-02-2002, 03:04 AM
I got a few books from the library and figure out my problem, but thanks anyhow. The best pointer i can give is use phpmyadmin. I did not know that the load
comand is not support though. Have you posted at phpwizard.net and devshed. They have a huge forum just for php and mysql if that helps.


I would use "," between fields and you can use quotes for text.


I used commas as delimmeter and '" for texts in my files if that helps.