1:目前在用的是社区版的infobright,不支持DML功能,只能用LOAD DATA方式导入数据。
如果元数据中有特殊控制字符,导入过程中经常会报错
2:
设置Reject File导入之前,设定 @BH_REJECT_FILE_PATH 和 @BH_ABORT_ON_COUNT 就可以忽略多少条导入失败的记录,并且将这些记录保存在指定文件
/** when the number of rows rejected reaches 10, abort process **/
set @BH_REJECT_FILE_PATH = ‘/tmp/reject_file‘;
set @BH_ABORT_ON_COUNT = 10;
BH_ABORT_ON_COUNT 设定为 -1 的话,表示永不忽略。
也可以设置 BH_ABORT_ON_THRESHOLD 选项,该选项表示有最多多少百分比的数据允许被忽略,因此该选项的值是小数格式,例如 BH_ABORT_ON_THRESHOLD = 0.03(表示3%)
导出时指定结束符此外,还可以在导出数据时制定结束符,并且设定忽略哪些转义字符(\、”、’ 等字符),例如:
select fields_list... into outfile ‘/tmp/outfile.csv‘ fields terminated by ‘||‘ ESCAPED BY ‘\\‘ lines terminated by ‘\r\n‘ from mytable;
或者,将行间隔符设定为其他特殊标识,例如:select fields_list… into outfile ‘/tmp/outfile.csv’ fields terminated by ‘||’ ESCAPED BY ‘\\’ lines terminated by ‘$$$$$\r\n’ from mytable;当然了,这种情况下,实际数据行中就不能存在 “$$$$$\r\n” 这个值了,否则会被当成换行标识。
3:
LOAD DATA LOCAL INFILE ‘E:\dim_ec_browser.txt‘ INTO TABLE dim_ec_browser FIELDS TERMINATED BY ‘\t‘
4:
SELECT * FROM tab_name INTO OUTFILE ‘/data/tabname.txt‘ FIELDS TERMINATED BY ‘\t‘ ENCLOSED BY ‘ " ‘ LINES TERMINATED BY ‘/n‘ ;