tablelist="
T1
T2
T3
"
HOST=127.0.0.1
PASSWD=pass
DATABASE=test
CMD="mysql -h$HOST -uroot -p$PASSWD $DATABASE -sN -e "
map[T1]="'BTC','ETH'"
map[T2]="'BTC2','ETH2'"
map[T3]="'BTC3','ETH3'"
START_TIME="unix_timestamp( '2021-09-27' )"
END_TIME="unix_timestamp( '2021-09-29' )"
function exportDiffData()
{
set -f
SQL="SELECT * FROM $1 where $START_TIME <= unix_time and unix_time < $END_TIME and symbol in ( ${map[${1}]} )"
echo $SQL
$CMD "$SQL" | sed 's/\t/,/g' > $1.csv
set +f
}
for table in $tablelist
do
echo $table
exportDiffData ${table}
done
'Database > MySQL' 카테고리의 다른 글
MySQL shell importTable() 사용하기 (0) | 2021.10.01 |
---|---|
MySQL shell exportTable() 사용하기 (0) | 2021.10.01 |
purge binary logs statement (0) | 2020.11.17 |
@@GLOBAL.GTID_PURGED cannot be changed: the added gtid set must not overlap with @@GLOBAL.GTID_EXECUTED (0) | 2020.11.06 |
Mysql 실행되는 로그 파일로 남기기 (0) | 2020.11.06 |