[ACCEPTED]-Import hex/binary data into mysql-blob

Accepted answer
Score: 28

You can use the SET part of LOAD DATA INFILE, and 4 you don't need the 0x escaping stuff:

1, 1, 123456FF
2, 1, aabbcc
3, 1, ddeeff

And 3 then you assign the column to a variable, and 2 then set the column to the UNHEXed version 1 of that variable:

LOAD DATA INFILE 'file' INTO TABLE `table` (column1, column2, @var1)
SET column3 = UNHEX(@var1)
Score: 0

Couldn't find any alternative. It looks 3 like the only way is the binary one (also, there 2 is already a bug/feature-request on mysql 1 regarding this).

Two things to consider:

  • text-file encoding when generating the input file;
  • character escaping (NEW-LINE, TAB, QUOTE, etc);

More Related questions