MySQL Table Cleanup
## This script will is usefull for cleanup the table
# 1. rename table customer_table to customer_table_currentdate
# 2. create table customer_table with schema customer_table_currentdate
# 3. Copy 1 month data to customer_table from customer_table_currentdate
# 1. rename table customer_table to customer_table_currentdate
# 2. create table customer_table with schema customer_table_currentdate
# 3. Copy 1 month data to customer_table from customer_table_currentdate
mysql -uprabhat -p'ab7^44' -e " use customermgt; rename table customer_table to customer_table_`date '+%Y%m%d'`; create table customer_table like customer_table_`date '+%Y%m%d'`; INSERT INTO customer_table SELECT * FROM customer_table_`date '+%Y%m%d'` where DATE(starttime) > '`date --date="1 months ago" +%Y-%m-%d`';" ;