4、查看中转表中的记录数(以备导入数据后进行对比)
select count(*) from cux_bill_temp;
5、去除导入时在表bill.csv中的关键字段的空格字符,以免影响导入。
update cux_bill_temp
set ASSEMBLY_ITEM=replace(ASSEMBLY_ITEM,' ',''),
COMPONENT_ITEM=replace(COMPONENT_ITEM,' ','');
6、查看是否有重复的选项(既是否重复了Item)
select assembly_item,component_item,min(row_num),count(*)
from cux_bill_temp
group by assembly_item,component_item
having count(*)>1;
如果有重复的Item,则要删除(或是重新合并)
delete cux_bill_temp
where row_num in (select min(row_num) from cux_bill_temp
group by assembly_item,component_item
having count(*)>1);
以下步骤为选做(如有重复才做,没有重复不做7-10)
7、再重新建立一个临时表(对于有重复数据,则只取一条数据,现取row_num最小的一条)
drop table cux_bill_a;
create table cux_bill_a
as
select assembly_item,
component_item,
component_quantity,
PLANNING_FACTOR,
component_yield_factor,
supply_type,
supply_subinventory,
OPTIONAL_disp,
MUTUALLY_EXCLUSIVE_O_disp,
attribute1,
min(row_num) row_num
from cux_bill_temp
group by assembly_item,
component_item,
component_quantity,
PLANNING_FACTOR,
component_yield_factor,
supply_type,
supply_subinventory,
OPTIONAL_disp,
MUTUALLY_EXCLUSIVE_O_disp,
attribute1;
