Loading a table from data in a text file
Posted by admin (Graham Ellis), 11 October 2003I'm often asked how to load data in a text file into a table. It can be done with load data infile, which has flexibility to handle different field and line delimiters, and can even handle fields that might or might not be encased in quotes. Here's an example that includes a load data infile using a number of the options.
Posted by Custard (Custard), 11 October 2003As an addendum, that may be 'deprecated' now,
last time I wanted to do this (on a solaris machine)
I had to run the mysql program with..
mysql -uUser -p --local-infile=1
... or it wouldn't work. Something to do with security afaicr.
I noted we didn't have to do it on the course, but we were using windows..
Posted by admin (Graham Ellis), 11 October 2003You can say
LOAD DATA LOCAL INFILE
LOAD DATA INFILE
and this will cause the data to be loaded from the client's disc rather than the server's disc. The --local-infile option enables / disables the LOAD DATA LOCAL INFILE capability - in other words, it controls whether or not you can load data from the client's disc. I don't think it effects the regular LOAD DATA INFILE command which loads data from the server's discs.
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho