Pages

How to restore single table from large mysql dump ?

In this post I will briefly explain how to restore single table from a large mysql dump file. Its not that much hard what it says :)

BTW, first you need to know how to dump the database, so no worries ,some time back I wrote a blog post how to take a database dump. Take a look at this.

OK so lets get back to topic,
Here is the simple command that you can make it happen.

 sed -n -e '/CREATE TABLE.*mytable/,/CREATE TABLE/p' mydump.sql > table.sql  

mytable is the table name that you want to extract from the dump file.
mydump is the large dump file that contains dumped data
table is the file that will create after . (contains table creation data as well as insert data)
SO that's all. enjoy it :)

No comments:

Post a Comment