[Nottingham] REading filesystem into MySQL query

singlecell singlecell at tesco.net
Thu Oct 13 17:10:52 BST 2005


> Does MySQL support  SQL 'COPY' 
> eg. COPY mytable  FROM 'flist' WITH DELIMITER '|' NULL AS '\N';

Try "LOAD DATA":

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'
     [REPLACE | IGNORE]
     INTO TABLE tbl_name
     [FIELDS
         [TERMINATED BY 'string']
         [[OPTIONALLY] ENCLOSED BY 'char']
         [ESCAPED BY 'char' ]
     ]
     [LINES
         [STARTING BY 'string']
         [TERMINATED BY 'string']
     ]
     [IGNORE number LINES]
     [(col_name_or_user_var,...)]
     [SET col_name = expr,...)]

see: http://dev.mysql.com/doc/refman/5.0/en/load-data.html

I guess the equivalent statement would be:
LOAD DATA INFILE 'flist' INTO TABLE mytable FILEDS TERMINATED BY '|'



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.14/131 - Release Date: 12/10/2005




More information about the Nottingham mailing list