Posted By

RICHARDP on 10/30/08


Tagged

sql table data import to load from tab delimited datafile


Versions (?)

Import data from tab - delimited datafile to SQL table.


 / Published in: SQL
 

Fields are tab delimited and need to match table schema. I've found the tab separator ASCII(009) preferable over using a comma.

The second version can help remove double quotation marks around character fields.

Don't forget the keyword LOCAL.

  1. > LOAD DATA LOCAL INFILE '/tmp/testdata.txt' INTO TABLE testtable FIELDS TERMINATED BY '\t';
  2.  
  3. > LOAD DATA LOCAL INFILE '/tmp/VICIDB/matltran.txt' INTO TABLE matltran FIELDS TERMINATED BY '\t' FIELDS OPTIONALLY ENCLOSED BY '"';

Report this snippet  

You need to login to post a comment.