美文网首页
Mysql 批量修改

Mysql 批量修改

作者: 六飞卡尔 | 来源:发表于2017-03-16 14:12 被阅读0次

    1、创建临时表-各业务敏感字段关系映射表

    CREATE TABLE `encrypt_user_data` (

    `uid` int(11) unsigned NOT NULL COMMENT '',

    `encrypt_bank_card_id` varchar(252) NOT NULL COMMENT '',

    `encrypt_phone` varchar(252) NOT NULL COMMENT '',

    `encrypt_contract_no` varchar(252) NOT NULL COMMENT 'encrypt_contract_no',

    `encrypt_email` varchar(252) NOT NULL COMMENT '',

    `encrypt_86_phone` varchar(252) NOT NULL COMMENT '',

    `encrypt_name` varchar(252) NOT NULL COMMENT '',

    `encrypt_identity_id` varchar(252) CHARACTER SET utf16 NOT NULL COMMENT '',

    `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',

    `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',

    PRIMARY KEY (`uid`)

    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户敏感加密数据';

    2、联表插入数据

    INSERT IGNORE INTO encrypt_user_data

    (uid,encrypt_bank_card_id,encrypt_phone,encrypt_contract_no,encrypt_email,encrypt_86_phone,encrypt_name,encrypt_identity_id)

    SELECT b.uid AS uid,a.encrypted_bank_card_id AS encrypt_bank_card_id ,

    a.encrypted_phone AS encrypt_phone ,a.encrypted_contract_no AS encrypt_contract_no,

    b.email_safe AS encrypt_email,b.phone_safe AS encrypt_86_phone,c.encrypted_name AS encrypt_name,

    c.encrypted_identity_id AS encrypt_identity_id

    FROM t_formax_user_info as b

    LEFT JOIN t_bank_card_pay_info as a on b.uid=a.uid

    LEFT JOIN t_user_base_info as c on b.uid=c.uid;

    3、更新各业务敏感字段值

    UPDATE customers,encrypt_user_data

    SET customers.email=encrypt_user_data.encrypt_email,customers.phone=encrypt_user_data.encrypt_86_phone,

    customers.id_number=encrypt_user_data.encrypt_identity_id

    WHERE customers.uid=encrypt_user_data.uid;

    相关文章

      网友评论

          本文标题:Mysql 批量修改

          本文链接:https://www.haomeiwen.com/subject/uaqjnttx.html