Using MySQL LOAD DATA INFILE with nonprintable character delimiters

本小妞迷上赌 提交于 2019-12-06 05:09:46

I got it.

LOAD DATA LOCAL INFILE 'myfile.txt' INTO TABLE my_table 
    CHARACTER SET UTF8 
    FIELDS TERMINATED BY X'01'
    LINES TERMINATED BY X'02'
    (col1, col2, col3);

You might try FIELDS TERMINATED BY _ascii 0x02. I don't know if it will work for LOAD DATA INFILE, but it works in SELECT (i.e., SELECT _ascii 0x61 yields 'a').

If you're using mysqlimport the format for hex values in fields-terminated-by and lines-terminated-by etc is:

mysqlimport --local --user=username --password=secret --ignore-lines=4 --default-character-set=UTF8 --fields-terminated-by=0x01 --lines-terminated-by=0x02 --verbose databasename thefiletoimport

You can try just sending the ascii char directly inside the string literal.. if your connection doesn't have a charset or encoding assigned, then mysql may simply accept it as a valid string. You'd have to do it through a network connection, or piping data to the mysql client. I don't think you're going to be able to type that in at a console.

FIELDS TERMINATED BY X'01'

works for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!