开发者

Possible to open a text file in a MYSQL stored procedure?

开发者 https://www.devze.com 2022-12-22 20:56 出处:网络
Is it possible to open and read from a text file in a MYSQL stored procedure? I have a text file with a list of about 50k telephone numbers, and want to write a stored procedure that will open the fil

Is it possible to open and read from a text file in a MYSQL stored procedure? I have a text file with a list of about 50k telephone numbers, and want to write a stored procedure that will open the file, read the 50k lines and store it as 开发者_开发技巧rows in a table. I cannot load the file directly using LOAD IN FILE as the table has additional columns that I have to set.

Thanks!


In the end I used LOAD IN FILE. Apparently you can set which columns get populated by using the SET keyword:

LOAD DATA LOCAL INFILE '/temp/input_file.txt' IGNORE INTO TABLE TEST.TEST_INSERT (INSERT_FIELD) SET VERSION=1, LIST_ID=ID_GEN(), CREATE_DATE=NOW(), CREATE_BY='TESTUSER';
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号