方法一:insert into pur_purchase_item_config select '',id,item_code,7,15,1.5,'SYSTEM',now(),
'SYSTEM',now() from hic_item where status in (-2,1,3,5,6);
缺点:会锁表,
方法二:
SELECT * INTO OUTFILE '/tmp/20130520itemtmp.txt' FIELDS TERMINATED BY ',' ENCLOSED BY '"'
FROM (SELECT id AS item_id,item_code,7 AS safe_stock_day,15 AS single_purchase_day,1.5 AS puchase_time_factor,'SYSTEM' AS creator_name,NOW() AS gmt_create,
'SYSTEM' AS modifier_name,NOW() AS gmt_modified FROM hic_item WHERE STATUS IN (-2,1,3,5,6)) t;
LOAD DATA INFILE '/tmp/20130520itemtmp.txt' IGNORE INTO TABLE pur_purchase_item_config FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'
(item_id,item_code,safe_stock_day,single_purchase_day,puchase_time_factor,creator_name,gmt_create,modifier_name,gmt_modified);
缺点:语句较复杂
'SYSTEM',now() from hic_item where status in (-2,1,3,5,6);
缺点:会锁表,
方法二:
SELECT * INTO OUTFILE '/tmp/20130520itemtmp.txt' FIELDS TERMINATED BY ',' ENCLOSED BY '"'
FROM (SELECT id AS item_id,item_code,7 AS safe_stock_day,15 AS single_purchase_day,1.5 AS puchase_time_factor,'SYSTEM' AS creator_name,NOW() AS gmt_create,
'SYSTEM' AS modifier_name,NOW() AS gmt_modified FROM hic_item WHERE STATUS IN (-2,1,3,5,6)) t;
LOAD DATA INFILE '/tmp/20130520itemtmp.txt' IGNORE INTO TABLE pur_purchase_item_config FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'
(item_id,item_code,safe_stock_day,single_purchase_day,puchase_time_factor,creator_name,gmt_create,modifier_name,gmt_modified);
缺点:语句较复杂