根据表A与表B关联字段,将B中字段更新到表A中去
A包含 号码,其他字段,
B包含 号码,ID
1. 创建临时表A1, A1 同时包含号码与ID,
2. 改变A1表的号码的字段名称, 删除A1表的号码列
3. 校验数据, 删除A表, 改变A1表的名称为A表
create table A1 as select A.usr_id as usr_ids ,B.* from KP_USR_USRID_RELATION A , table_b B where A.usr_nbr = B.usr_nbr; //根据号码,ID关系创建临时表
alter table A1 drop column usr_nbr // 删除临时表中号码字段
alter table A1 rename column usr_ids to usr_nbr //改变临时表的ID字段的名称
drop table table_b //删除原表
alter table A1 rename to table_b //将临时表的名称改为原表名称
A包含 号码,其他字段,
B包含 号码,ID
1. 创建临时表A1, A1 同时包含号码与ID,
2. 改变A1表的号码的字段名称, 删除A1表的号码列
3. 校验数据, 删除A表, 改变A1表的名称为A表
create table A1 as select A.usr_id as usr_ids ,B.* from KP_USR_USRID_RELATION A , table_b B where A.usr_nbr = B.usr_nbr; //根据号码,ID关系创建临时表
alter table A1 drop column usr_nbr // 删除临时表中号码字段
alter table A1 rename column usr_ids to usr_nbr //改变临时表的ID字段的名称
drop table table_b //删除原表
alter table A1 rename to table_b //将临时表的名称改为原表名称