mysql如何重复数据合并_如何合并两个相同结构的MySQL数据库

bd96500e110b49cbb3cd949968f18be7.png

Here's my situation. I've got my current database (let's call it current_db) that is up to date, but its data are incomplete because of a recent crash. Some datas have been deleted, and this delete goes from 2 years ago to yesterday.

I've got a backup of this database (let's call it backup_db), from November 2013, whose datas are complete up to November 2013. Since current_db holds some data from between November 2013 and February 2014, I don't want to just scrap it, and work from the backup. So I'd like to import current_db into backup_db ignoring duplicated data.

I've seached for methods to do that, but couldn't find any relevant ones. I've come across a few SELECT queries, but they're all simplistic ones. My database holds 20 tables, and I don't really see myself building an immense query to import all of this. Is there any other way ?

Thanks

解决方案Use phpMyAdmin ( Install if you still don't use it )

Go to the current database

click import and import the other database

Possible Issues :

The max file upload size in phpmyadmin may be 2MB.To solve this

increase the maximum file upload size php.ini

Assume you have a schema s1 and a schema s2.

To insert all rows of a table in s1 into a table in s2, while overwriting existing lines, you can use:

REPLACE INTO s2.table_name

SELECT * FROM s1.table_name;

If you do not want to touch existing lines:

INSERT INTO s2.table_name

SELECT * FROM s1.table_name

ON DUPLICATE KEY IGNORE;

Comment here if you have any issues.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值