It is my test-tab.csv
as below.
\data\ hello
Notice:there is a \t
between \
and h
in test-tab.csv
,that is to say ,showing in vim(set list).
\data\^Ihello$
Prepare for loading data.
create table tab(`f1` varchar(10),`f2` varchar(10));
Load the data into table tab
.
LOAD DATA LOCAL INFILE "f:/test-tab.csv"
INTO TABLE tab
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\r\n' \W;
And have a look.
select * from tab;
+------------+------+
| f1 | f2 |
+------------+------+
| data hello| NULL |
+------------+------+
1 row in set (0.000 sec)
How can i load data into table tab
as below.
select * from tab;
+------------+------+
| f1 | f2 |
+------------+------+
| \data\ | hello|
+------------+------+
1 row in set (0.000 sec)
Constraint condition:keep the data format in test-tab.csv
unchanged.
The problem seems to be escaping the tab.
FIELDS TERMINATED BY '\t' ESCAPED BY ''
If that does not work, is there some character that is not used in the data? Say |
? Then
FIELDS TERMINATED BY '\t' ESCAPED BY '|'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With