patternsqlModerate
Can mysql restore a single table from a large mysqldump?
Viewed 0 times
canrestoremysqldumpmysqlsinglelargefromtable
Problem
What is the best way to restore a single table from a large (~5GB) database mysqldump file?
update:
I have found solutions (posted below) using command line tools to parse the table, but is there a way to do this with mysqlimport?
update:
I have found solutions (posted below) using command line tools to parse the table, but is there a way to do this with mysqlimport?
Solution
I have found two solutions, one using
and one using awk
grep -n "Table Structure" mydump.sql
# identify the first and last line numbers (n1 and n2) of desired table
sed -n n1,n2p mydump.sql > mytable.sql # (e.g. sed -n 48,112p)and one using awk
awk '/Table Structure for table .table1./, /Table structure for table .cultivars./{print}' mydump.sql > mytable.sqlCode Snippets
grep -n "Table Structure" mydump.sql
# identify the first and last line numbers (n1 and n2) of desired table
sed -n n1,n2p mydump.sql > mytable.sql # (e.g. sed -n 48,112p)awk '/Table Structure for table .table1./, /Table structure for table .cultivars./{print}' mydump.sql > mytable.sqlContext
StackExchange Database Administrators Q#14716, answer score: 10
Revisions (0)
No revisions yet.