# 创建分库分表 CREATE TABLE `component` ( `COMPONENT_NAME` varchar(100) NOT NULL, `ROOT_LOCATION` varchar(255) DEFAULT NULL, `LAST_UPDATED_STAMP` datetime DEFAULT NULL, `LAST_UPDATED_TX_STAMP` datetime DEFAULT NULL, `CREATED_STAMP` datetime DEFAULT NULL, `CREATED_TX_STAMP` datetime DEFAULT NULL, PRIMARY KEY (`COMPONENT_NAME`), KEY `COMPONENT_TXSTMP` (`LAST_UPDATED_TX_STAMP`), KEY `COMPONENT_TXCRTS` (`CREATED_TX_STAMP`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 dbpartition by hash(COMPONENT_NAME) tbpartition by YYYYDD(LAST_UPDATED_TX_STAMP) tbpartitions 4; Query OK, 0 rows affected (0.77 sec)
# 查看分表情况 mysql> show topology from component; +------+----------------------------------------------------------+-------------+ | ID | GROUP_NAME | TABLE_NAME | +------+----------------------------------------------------------+-------------+ | 0 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0000_RDS | component_0 | | 1 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0000_RDS | component_1 | | 2 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0000_RDS | component_2 | | 3 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0000_RDS | component_3 | | 4 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0001_RDS | component_0 | | 5 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0001_RDS | component_1 | | 6 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0001_RDS | component_2 | | 7 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0001_RDS | component_3 | | 8 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0002_RDS | component_0 | | 9 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0002_RDS | component_1 | | 10 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0002_RDS | component_2 | | 11 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0002_RDS | component_3 | | 12 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0003_RDS | component_0 | | 13 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0003_RDS | component_1 | | 14 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0003_RDS | component_2 | | 15 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0003_RDS | component_3 | | 16 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0004_RDS | component_0 | | 17 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0004_RDS | component_1 | | 18 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0004_RDS | component_2 | | 19 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0004_RDS | component_3 | | 20 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0005_RDS | component_0 | | 21 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0005_RDS | component_1 | | 22 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0005_RDS | component_2 | | 23 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0005_RDS | component_3 | | 24 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0006_RDS | component_0 | | 25 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0006_RDS | component_1 | | 26 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0006_RDS | component_2 | | 27 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0006_RDS | component_3 | | 28 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0007_RDS | component_0 | | 29 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0007_RDS | component_1 | | 30 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0007_RDS | component_2 | | 31 | BATMAN_SPLIT_1503372442489ZQPDBATMAN_SPLIT_JRMC_0007_RDS | component_3 | +------+----------------------------------------------------------+-------------+ 32 rows in set (0.04 sec)
|