Skip to main content

Posts

Showing posts from February, 2017

Load Data Infile - MySQL

Load data infile will read the content from the text file and insert into table. This process is very fast in MySQL. Below is the Syntax suggested by MySQL in their documentation: LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE ' file_name ' [REPLACE | IGNORE] INTO TABLE tbl_name [PARTITION ( partition_name ,...)] [CHARACTER SET charset_name ] [{FIELDS | COLUMNS} [TERMINATED BY ' string '] [[OPTIONALLY] ENCLOSED BY ' char '] [ESCAPED BY ' char '] ] [LINES [STARTING BY ' string '] [TERMINATED BY ' string '] ] [IGNORE number {LINES | ROWS}] [( col_name_or_user_var ,...)] [SET col_name = expr ,...] Will look into some of the procedures to load data into table using an external text file: Procedure 1: Text file contains header: LOAD DATA INFILE ‘path/to/example.csv’ INTO TABLE example FIELDS TERMINATED BY ‘,’ LINES TERMINATED BY ‘\n’ IGNORE