Your ads will be inserted here by
Easy Plugin for AdSense.
Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.
restore a single table from a full mysql mysqldump file
Extract tables with Create, This is safer option
sed -n -e '/CREATE TABLE.*users/,/UNLOCK TABLES/p' all_spark.sql > users1.sql
Extract table with DROP Table
sed -n -e '/DROP TABLE.*users/,/UNLOCK TABLES/p' fulldump.sql > users.sql
# identify the first and last line numbers (n1 and n2) of desired table
grep -n "Table Structure" mydump.sql
# (e.g. sed -n 48,112p)
sed -n n1,n2p mydump.sql > mytable.sql
## This script will only get you first found table, it will not work if you have diff table with same name.
#!/bin/bash
### This script is from jasny / mysql_splitdump.sh found in githut
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit
fi
Your ads will be inserted here by
Easy Plugin for AdSense.
Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.
if [ $# -ge 2 ] ; then
csplit -s -ftable $1 "/-- Table structure for table/" "%-- Table structure for table `$2`%" "/-- Table structure for table/" "%40103 SET TIME_ZONE=@OLD_TIME_ZONE%1"
else
csplit -s -ftable $1 "/-- Table structure for table/" {*}
fi
[ $? -eq 0 ] || exit
mv table00 head
FILE=`ls -1 table* | tail -n 1`
if [ $# -ge 2 ] ; then
mv $FILE foot
else
csplit -b '%d' -s -f$FILE $FILE "/40103 SET TIME_ZONE=@OLD_TIME_ZONE/" {*}
mv ${FILE}1 foot
fi
for FILE in `ls -1 table*`; do
NAME=`head -n1 $FILE | cut -d$'x60' -f2`
cat head $FILE foot > "$NAME.sql"
done
rm head foot table*
Comments are closed.