< Browse > Home / Linux / Unix, Programming / Blog article: Extract single/multiple tables from MySQL dumpfile

| Mobile | RSS

Extract single/multiple tables from MySQL dumpfile

December 2nd, 2010 | 2 Comments | Posted in Linux / Unix, Programming

An year back I posted on how to extract a single table from a MySQL dump file. Today, I decided to write a shell script to automate the whole process. Now it is possible to extract a single table or a range of tables from a dump file with a single command.

Usage

The script can be invoked with and without any parameters. The script usage is

./extract_table.sh mydumpfile.sql tablename tablename2

All parameters are optional. If the third argument is provided, the script will extract all tables from tablename to tablename2. If it is not specified, only tablename will be extracted.

If first and/or second argument(s) are/is omitted, the script goes into interactive mode, allowing you to select the file and table name. The interactive mode also allows you to view a list of all the tables in the dump file. You can extract a group of tables or a single table.

License

It took me a few hours to write the code. So, with the hope that someone will find this useful, I am releasing the code under MIT, BSD and GPL licenses. Feel free to contact me, if you are a fan of another license :)

Download

The script can be downloaded from Github. The current version is 1.0.
MySQL Dump Table Extractor

Leave a Reply 28837 views, 1 so far today |
Follow Discussion

2 Responses to “Extract single/multiple tables from MySQL dumpfile”

Trackbacks

  1. Joyce Babu » Blog Archive » Extract single table from a mysql dump  
  2. Which license should I use for my code? - Stack Overflow