Last active
August 29, 2015 14:07
-
-
Save juniorplenty/409cf5d2a086c0b3c852 to your computer and use it in GitHub Desktop.
Archive Impressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SRCDB=honeydew_production | |
SRCTABLE=impressions | |
DSTDB=honeydew_archive_2012 | |
DSTTABLE=impressions | |
SQL="alter table $DSTDB.$DSTTABLE disable keys" | |
echo "$SQL" | |
echo "$SQL" | mysql | |
SID=3962169320 | |
EID=4727791949 | |
INC=100000 | |
for ((sid=SID; sid<EID; sid+=INC)); do | |
eid=$((sid+INC)) | |
if ((eid>EID)); then | |
eid=$EID | |
fi | |
SQL="insert into $DSTDB.$DSTTABLE select * from $SRCDB.$SRCTABLE where id>=$sid and id<$eid" | |
echo "$SQL" | |
echo "$SQL" | mysql | |
done | |
SQL="alter table $DSTDB.$DSTTABLE enable keys" | |
echo "$SQL" | |
echo "$SQL" | mysql | |
echo "DONE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for year in {2012..2012} ; do | |
for week in {27..39} ; do | |
partition="y$year"`printf "w%02d" $week` | |
echo "alter table honeydew_production.impressions drop partition $partition" | |
echo "alter table honeydew_production.impressions drop partition $partition" | mysql | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment