Examples for business, study, careers, love, and more...
Examples :: MYSQL Examples :: Example of Load Data Infile Mysql Statement

Example of Load Data Infile Mysql Statement:

LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx';

LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test IGNORE 1 LINES;

LOAD DATA INFILE 'data.txt' INTO TABLE table2 FIELDS TERMINATED BY ',';

LOAD DATA INFILE 'data.txt' INTO TABLE table2 FIELDS TERMINATED BY ' ';

CREATE TABLE jokes (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, joke TEXT NOT NULL);
LOAD DATA INFILE '/tmp/jokes.txt' INTO TABLE jokes FIELDS TERMINATED BY '' LINES TERMINATED BY ' %% ' (joke);

Example of Mysql Load Data Infile


LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL]
INFILE
'file_name'
[REPLACE | IGNORE]
INTO TABLE
tbl_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]
[(col_name_or_user_var,...)]
[SET col_name = expr,...]