关于在不同的数据库中的同步表的数据

Posted __Feng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于在不同的数据库中的同步表的数据相关的知识,希望对你有一定的参考价值。

实现功能:把数据库Db1中ammeter表的数据同步到Db2中的meter_bill表中去

代码如下:

INSERT INTO db2.meter_bill (
    oms_meter_id,
    house_id,
    meter_no,
    meter_number,
    first_quantity,
    zoom,
    last_month,
    last_month_quantity,
    last_month_create_date,
    current_month,
    current_month_quantity,
    current_use_quantity,
    remark,
    create_by,
    creation_date,
    last_updated_by,
    last_updated_date,
    delete_flag
)
SELECT _id,
    house_id,
    water_meter_no,
    ext_meter_no,
    first_quantity,
    zoom,
    last_month,
    last_month_quantity,
    last_month_create_date,
    current_month,
    current_month_quantity,
    current_use_quantity,
    remark,
    create_by,
    creation_date,
    last_updated_by,
    last_updated_date,
    delete_flag
FROM db1.ammeter

实际上就是把从db1的ammeter表中查出来的数据,插入到db2中的meter_bill表中去,最主要的是字段名要一一对应,mark!

以上是关于关于在不同的数据库中的同步表的数据的主要内容,如果未能解决你的问题,请参考以下文章