使用这样的数据:
* id txns_date sale
* 1234 01JAN2011 100
* 1235 03FEB2011 101
* 1236 04MAR2011 102
我尝试了以下代码,但txns_date字段都是NULL
;
create table tran(
id int,
txns_date date,
sale dec(10,2)
);
load data local INFILE 'c:/Projects/tran.txt' into table tran
fields terminated by '\t'
lines terminated by '\n'
ignore 1 lines
(id,@var1,sale)
set txns_date = STR_TO_DATE(@var1,'%d%b%Y')
;