Skip to content

Instantly share code, notes, and snippets.

@eegrok
Created November 22, 2014 05:23
Show Gist options
  • Save eegrok/ea57a8cb0db5c1bdfdd7 to your computer and use it in GitHub Desktop.
Save eegrok/ea57a8cb0db5c1bdfdd7 to your computer and use it in GitHub Desktop.
extract individual tables from database dump, for import -- mysql
touch /tmp/empty
ack "Table structure" /path/to/database_backup.sql /tmp/empty
it spits out something like this:
...
56160:-- Table structure for table `sub_human`
56195:-- Table structure for table `fool`
56385:-- Table structure for table `fool_games`
56465:-- Table structure for table `fool_games_old`
56657:-- Table structure for table `fool_games_texts`
56795:-- Table structure for table `fool_old`
57828:-- Table structure for table `fool_scorecard`
57919:-- Table structure for table `fool_scorecard_old`
58293:-- Table structure for table `fool_scorecard_texts`
58573:-- Table structure for table `fool_texts`
59450:-- Table structure for table `test_app`
59502:-- Table structure for table `something_180`
....
then I used the line numbers above to get all the fool tables into one sql file
sed -n 56195,59450p /path/to/database_backup.sql > fool_tables.sql
and imported that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment