tags:

views:

31

answers:

2

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 to 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?

+3  A: 

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.

Tatu Ulmanen
+1 :) @hekevintran u might want to check for create table also in dump B and C
Richie
Sweet! Thanks for the explanation.
hekevintran
A: 

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/

kv