Import data from tab - delimited datafile to SQL table.


/ Published in: SQL
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.