Extract a single table from a MySQL dump

You have a 7 GB dump with 127 tables, but locally you only need three of them — users, orders, products. Here's why the usual sed/grep tricks break, and how to pull exactly the tables you want (with their foreign keys) in a few clicks.

Not every job needs the whole database. When you're building a feature locally, you rarely want a full production dump filling your disk and taking an hour to import. You want the handful of tables the feature actually touches.

The same is true when you're debugging a single table — reproducing a data issue in orders doesn't require the other 126 tables — or doing a partial migration, where only a few tables move to a new service. In all of these cases the question is the same: how do I get just these tables out of a giant dump, cleanly and quickly?

The sed/grep approach and why it breaks

The classic answer is to slice the file with sed between the section headers mysqldump writes for each table:

# pull the users table out of a mysqldump file
sed -n '/-- Table structure for table `users`/,/-- Table structure for table/p' dump.sql > users.sql

It looks clever, and on a small, tidy dump it might even work once. On a real 7 GB file it falls apart in a lot of subtle ways:

You end up piling awk onto grep onto sed, testing on subsets, and still not trusting the result. There's a better way.

Extract tables with DumpCleaner

DumpCleaner parses the dump properly — it understands statement boundaries, multi-line INSERTs, backticks and comments — so it always cuts on the right lines. Extracting the tables you need takes four steps:

  1. Drag your .sql dump in. DumpCleaner streams the file, so a 7 GB dump opens with constant memory instead of loading the whole thing.
  2. Read the auto-detected table list. Every table is parsed out and listed with its row count and size — no scrolling through millions of lines to find what's there.
  3. Pick the tables you want. Tick users, orders and products, or type a regex / exclude pattern such as *_logs to drop whole groups in one go.
  4. Include foreign key parents and export. Optionally pull in referenced parent tables automatically, then export a clean, importable file.

A few things make this a lot less fiddly than shell tools:

Just the tables you need — nothing else

DumpCleaner extracts specific tables from dumps of any size — streaming, with constant memory, and with foreign keys resolved for you. Native macOS & iPadOS app, one-time purchase.

Download on the App Store

Frequently asked questions

Can I extract multiple tables at once?

Yes. Tick as many tables as you like — users, orders and products together — and DumpCleaner writes them all into a single file in one pass.

Does it keep foreign key dependencies?

Optionally, yes. Turn on include foreign key dependencies and any parent table referenced by your selection is pulled in automatically, so the extract imports without constraint errors.

Can I exclude tables by pattern?

Yes. Use exclude patterns such as *_logs or *_sessions, or a regular expression, to drop whole groups of tables instead of unticking them one at a time.

Does it work with PostgreSQL?

Yes. DumpCleaner reads MySQL, MariaDB and PostgreSQL (pg_dump) dumps, and handles schema-qualified names like public.users when extracting tables.

Stop fighting sed and grep

Drag, pick your tables, export. DumpCleaner pulls exactly the tables you need — with their foreign keys — out of any dump.

Download on the App Store