Inserting a text file to MySQL

Sundar plug-discuss@lists.plug.phoenix.az.us
Tue, 11 Feb 2003 08:28:37 -0700


Brian - I don't want to load a binary file, just a text file.
Mike - I don't want to load a text file to a table, rather to just one 
column. Something like CLOB in oracle.

Sundar

Mike Starke wrote:

>On Mon, Feb 10, 2003 at 05:41:28PM -0700, David A. Sinck wrote:
>/_
>/_
>/_\_ SMTP quoth Sundar on 2/10/2003 16:16 as having spake thusly:
>/_\_
>/_\_ Thanks David,
>/_\_ 
>/_\_ When you say 
>/_\_ 
>/_\_ insert into foo ( [contents of file]);
>/_\_ 
>/_\_ Does it mean
>/_\_ 
>/_\_ insert into foo ( filename );
>/_\_ 
>/_\_ I am just trying to achieve it with a SQL query.
>/_
>/_Ah.  Not quite sure how to do that in one query without resorting to
>/_the docs or writing a perl script.  I've done it via the later.  
>/_
>/_Both are left as an excercise for the reader.  :-)
>
>Excercise almost over ..... look at "LOAD DATA .. INFILE .."
>
>LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'
>[REPLACE | IGNORE]
>INTO TABLE tbl_name
>[FIELDS
>[TERMINATED BY '\t']
>[[OPTIONALLY] ENCLOSED BY '']
>[ESCAPED BY '\\' ]
>]
>[LINES TERMINATED BY '\n']
>[IGNORE number LINES]
>[(col_name,...)]
>
>More info at:
>http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#LOAD_DATA
>
>---------------------------------------------------
>PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
>To subscribe, unsubscribe, or to change  you mail settings:
>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>  
>