PHPRO.ORG

Get Single Table From Mysqldump File

Get Single Table From Mysqldump File

This is a simple one liner that people seem to need more often than I would have expected, and yet...

This simple line will extract a single table from a file created by mysqldump. In this example, the table named my_nice_table is extracted from the mysqldump file named db_dump.sql and a new file created with the name my_nice_table.sql which contains the required SQL.

sed -n -e '/DROP TABLE.*`my_nice_table`/,/UNLOCK TABLES/p' db_dump.sql > my_nice_table.sql