You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
-- ALTER TABLE t_base_person CONVERT TO CHARACTER SET gbk COLLATE gbk_chinese_ci;
数 据 清 洗 分 两 种 情 况
( 1 ) 、 校 验 上 报 的 数 据 字 段 , 是 不 是 在 范 围 内 , 校 验 即 可 , 不 扩 展 其 它 字 段
比 如 : 用 户 上 报 了 一 条 学 生 作 业 得 分 数 据 , 但 学 生 的 ID , 不 在 学 生 表 的 ID 范 围 内
( 2 ) 、 校 验 上 报 的 数 据 字 段 , 是 不 是 在 范 围 内 , 除 校 验 外 , 需 要 扩 展 其 它 字 段
比 如 : 用 户 上 报 了 一 条 学 生 作 业 得 分 数 据 , 需 要 在 检 查 zy_id 是 否 合 法 的 前 提 下 , 扩 展 出 zy_name 字 段
-- 下面分别进行讨论:
-- 增加 check_flag字段
-- ALTER TABLE `huanghai`.`t_zy_score` ADD COLUMN `check_flag` smallint NOT NULL DEFAULT 0 COMMENT '0: 待校验, 1: 校验成功, -1: 校验失败';
-- 添加check_flag字段索引
-- ALTER TABLE `huanghai`.`t_zy_score` ADD INDEX(`check_flag`);
-- 还原现场
update t_zy_score set check_flag = 0 , zy_name = null ;
-- 第一种情况对不上的修改为-1
update t_zy_score as t1 left join t_base_person as t2 on t1 . person_id = t2 . person_id set t1 . check_flag = - 1 where t2 . person_id is null limit 100 ;
-- 第二种情况对不上的,保留扩展字段为空
update t_zy_score as t1 left join t_zy_main as t2 on t1 . zy_id = t2 . zy_id set t1 . zy_name = t2 . zy_name where t1 . zy_name is null limit 100 ;
update t_zy_score as t1 set t1 . check_flag = - 1 where t1 . zy_name is null limit 100 ;
-- 最终修改正确标识
update t_zy_score as t1 set check_flag = 1 where check_flag = 0 limit 100 ;
select * from t_zy_score