Tuesday, August 25, 2009

Insert data into mysql from text file


Unload data into a text file.
Import data into a excel sheet. Then save the file again as .txt(Tab delimited) file.
Export file to your mysql server. vi the .txt file in linux. Then save the file using following command.
  • :%s/tab/|/g ---------->Then enter.
  • :wq!  ------------->Save the file
  • LOAD DATA INFILE "table.txt" INTO TABLE table
    FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'
    ----> Load data to mysql server

No comments:

Post a Comment