Friday, 24 January 2014

Load Data Infile

Working with file.csv is always really boring. However, today I've put aside this opinion and I'm going to try it out.

Following you'll find an example :

CREATE TABLE `my_table` (
 `campo1` BIGINT(20) NOT NULL,
 `campo2` BIGINT(20) NULL DEFAULT NULL,
 `campo3` VARCHAR(255) NULL DEFAULT NULL,
 `campo4` VARCHAR(255) NULL DEFAULT NULL,
 `campo5` BIGINT(20) NULL DEFAULT NULL,
 PRIMARY KEY (`campo2`)
)COLLATE='latin1_swedish_ci' ENGINE=InnoDB;


MYSQL> load data infile 'file.csv' into table my_table fields terminated by ';' optionally enclosed by '"' lines terminated by '\n';

This is the row :

AAAAAA;2;2;"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";1

That's all.

See you in my next blog.

Byeeeee

No comments:

Post a Comment