@dawn
2016-05-19T08:54:32.000000Z
字数 1990
阅读 683
payment
一.目前Payment的数据存储、备份方案
二.相关人员对历史数据的需求
三.对数据的要求
四.具体的操作方案
#查看表的分区信息mysql> select partition_name part, partition_expression expr, partition_description descr, table_rows from information_schema.partitions where table_schema = schema() and table_name='user_credit';+---------+----------------------+--------+------------+| part | expr | descr | table_rows |+---------+----------------------+--------+------------+| p201604 | TO_DAYS(create_date) | 736450 | 302 || p201605 | TO_DAYS(create_date) | 736481 | 63 || p201606 | TO_DAYS(create_date) | 736511 | 50 || p201607 | TO_DAYS(create_date) | 736542 | 65 || p201608 | TO_DAYS(create_date) | 736573 | 69 || p201609 | TO_DAYS(create_date) | 736603 | 61 || p201610 | TO_DAYS(create_date) | 736634 | 77 || p201611 | TO_DAYS(create_date) | 736664 | 65 || p201612 | TO_DAYS(create_date) | 736695 | 62 || p201701 | TO_DAYS(create_date) | 736726 | 73 || p201702 | TO_DAYS(create_date) | 736754 | 55 || p201703 | TO_DAYS(create_date) | 736785 | 57 || p201704 | TO_DAYS(create_date) | 736815 | 0 |......#找出时间最早的一个分区进行删除操作mysql> alter table user_credit drop partition p201604;Query OK, 0 rows affected (1.33 sec)Records: 0 Duplicates: 0 Warnings: 0#删除成功mysql> select partition_name part, partition_expression expr, partition_description descr, table_rows from information_schema.partitions where table_schema = schema() and table_name='user_credit';+---------+----------------------+--------+------------+| part | expr | descr | table_rows |+---------+----------------------+--------+------------+| p201605 | TO_DAYS(create_date) | 736481 | 63 || p201606 | TO_DAYS(create_date) | 736511 | 50 || p201607 | TO_DAYS(create_date) | 736542 | 65 || p201608 | TO_DAYS(create_date) | 736573 | 69 || p201609 | TO_DAYS(create_date) | 736603 | 61 || p201610 | TO_DAYS(create_date) | 736634 | 77 |......