开发者

Restoring a table in MySQL from multiple dumps

开发者 https://www.devze.com 2022-12-14 06:02 出处:网络
I have a MySQL database that I have performed a couple dumps on.I have these files: dumpA, dumpB, dumpC

I have a MySQL database that I have performed a couple dumps on. I have these files: dumpA, dumpB, dumpC

dumpA contains all the tables at the time of the dump

dumpB and dumpC contains only table T

Between dumps I truncated table T so dumpA contains the primary keys 1-100 for table T, dumpB 101-200, and dumpC 201-300.

I want t开发者_如何转开发o restore table T completely.

How do I import only table T from dumpA which contains other tables?

Once I do that, will importing dumpB truncate table T so that the data from dumpA disappears?


The dumps are just plain SQL which you can edit by hand. Just take out the declarations of table T from dumpA, and drop it into another file. Then make sure that dumpB and dumpC don't contain anything that would destroy the previous dump such as TRUNCATE or DROP TABLE etc. In fact, you can take all table creation queries out from dumpB and dumpC alltogether as they're not needed.

I'm not aware that MySQL can do any sort of filtering to the data when importing, so this is the easiest way to go.


Instead of doing it manually, you may use following script to extract table T from each of the dumps and use that. http://kedar.nitty-witty.com/blog/mydumpsplitter-extract-tables-from-mysql-dump-shell-script/

0

精彩评论

暂无评论...
验证码 换一张
取 消