数据库命令
我有两个数据库,分别有一个表在这两个数据库中,现在我想将第二个数据库中的表数据合并到数据库1的表中。
就是我需要合并某个特定日期之后的数据。
比如我的两个数据库分别是database1 和 database2,表db_table1 在database1中,表db_table2 在database2 中,我要把db_table2 中的内容复制到database1中,我只需要复制2015年5月20号之后的内容,有没有好的建议呢?
你并没有提到你的日期格式以及表的细节,你可以选择转储。
mysqldump database1 table1 --where="date_column BETWEEN '2015-05-20 00:00:00' and '2015-07-12 00:00:00'" > your-required.sql 你可以这样:
1)确保两个表相同。
2)在database1中给 db_table1留一个备份。
3)插入db_table2中的数据
在数据库命令窗口插入:
database1.db_table1 select * from database2.db_table2 where datefield > '2015-20-05' 不错哦!!!
static/image/common/sigline.gif
http://pic.yupoo.com/cjzihmxkq_v/BW3GBpl5/medium.jpg 我也想了解,请大家都说说
static/image/common/sigline.gif
http://pic.yupoo.com/cjzihmxkq_v/BW3GBpl5/medium.jpg
页:
[1]