V
V
vladimirchelyabinskiy2014-08-21 22:04:58
MySQL
vladimirchelyabinskiy, 2014-08-21 22:04:58

MySQL how to load a file with strings through the LOAD DATA INFILE command and assign them an MD5 hash?

There is a file of the form:
1
2
3
4
5
6
there is a table with 2 columns text , md5
I need to simultaneously add lines from the file to the text field and md5 hash from the line in the file to the md5 field how to implement this through the LOAD DATA INFILE command? Please provide an example code, I'm dumb.
well, if anyone can, that is, the task is more difficult, I have 1 database and 256 tables.
example of table names 00,01,2f,3d,8f, that is, all POSSIBLE combinations from the character set 0123456789ABCDEF (16) = 256 there are text and md5 fields, I need the same script, just so that the script automatically determines what and in which database to put
it yes, if the hash from a string, for example, 32523452, starts with 2f, then it goes to table 2f, etc.
whether it is possible to make it means of language SQL? If yes then give an example I'm stupid.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
egor_nullptr, 2014-08-22
@egor_nullptr

load data infile 'data.txt'
into table `table` (text)
set `md5` = md5(`text`);

Accept condolences.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question