-- drop table poms_status;
CREATE TABLE `poms_status` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`mid` varchar(64) NOT NULL COMMENT '传感器编码',
`receive_time` varchar(255) DEFAULT NULL COMMENT '接收数据时间,格式hh:mm:ss',
`val1` double DEFAULT NULL COMMENT '记录值1',
`val2` double DEFAULT NULL COMMENT '记录值2',
`val3` double DEFAULT NULL COMMENT '记录值3',
`val4` double DEFAULT NULL COMMENT '记录值4',
`product` varchar(255) DEFAULT NULL COMMENT '产品',
`paint` varchar(255) DEFAULT NULL COMMENT 'paint',
`line` varchar(255) DEFAULT NULL COMMENT 'line',
`receive_date` varchar(255) NOT NULL COMMENT '接收数据日期,格式:yyyy-mm-dd',
`status` smallint(6) DEFAULT NULL COMMENT '状态,1:正常,2:报警',
`warn_info` varchar(500) DEFAULT NULL COMMENT '报警说明',
`type` varchar(64) DEFAULT NULL COMMENT '传感器类型',
PRIMARY KEY (`id`,`receive_date`),
KEY `INX01` (`mid`,`receive_time`)
) ENGINE=MyISAM AUTO_INCREMENT=750943 DEFAULT CHARSET=utf8 COMMENT='传感器状态'
partition by range COLUMNS(`receive_date`)
(PARTITION p20200801 VALUES LESS THAN ('2020-08-01') ,
PARTITION p20200802 VALUES LESS THAN ('2020-08-02') ,
PARTITION p20200803 VALUES LESS THAN ('2020-08-03'),
PARTITION p20200804 VALUES LESS THAN ('2020-08-04'),
PARTITION p20200805 VALUES LESS THAN ('2020-08-05'),
PARTITION p20200806 VALUES LESS THAN ('2020-08-06'),
PARTITION p20200807 VALUES LESS THAN ('2020-08-07'),
PARTITION p20200808 VALUES LESS THAN ('2020-08-08'),
PARTITION p20200809 VALUES LESS THAN ('2020-08-09'),
PARTITION p20200810 VALUES LESS THAN ('2020-08-10'),
PARTITION p20200811 VALUES LESS THAN ('2020-08-11'),
PARTITION p20200812 VALUES LESS THAN ('2020-08-12'),
PARTITION p20200813 VALUES LESS THAN ('2020-08-13'),
PARTITION p20200814 VALUES LESS THAN ('2020-08-14'),
PARTITION p20200815 VALUES LESS THAN ('2020-08-15'),
PARTITION p20200816 VALUES LESS THAN ('2020-08-16'),
PARTITION p20200817 VALUES LESS THAN ('2020-08-17'),
PARTITION p20200818 VALUES LESS THAN ('2020-08-18'),
PARTITION p20200819 VALUES LESS THAN ('2020-08-19'),
PARTITION p20200820 VALUES LESS THAN ('2020-08-20'),
PARTITION p20200821 VALUES LESS THAN ('2020-08-21'),
PARTITION p20200822 VALUES LESS THAN ('2020-08-22'),
PARTITION p20200823 VALUES LESS THAN ('2020-08-23'),
PARTITION p20200824 VALUES LESS THAN ('2020-08-24'),
PARTITION p20200825 VALUES LESS THAN ('2020-08-25'),
PARTITION p20200826 VALUES LESS THAN ('2020-08-26'),
PARTITION p20200827 VALUES LESS THAN ('2020-08-27'),
PARTITION p20200828 VALUES LESS THAN ('2020-08-28'),
PARTITION p20200829 VALUES LESS THAN ('2020-08-29'),
PARTITION p20200830 VALUES LESS THAN ('2020-08-30'),
PARTITION p20200831 VALUES LESS THAN ('2020-08-31')
);
alter table poms_status add partition(partition p20200901 VALUES LESS THAN ('2020-09-01') ENGINE = MyISAM);
alter table poms_status add partition(partition p20200902 VALUES LESS THAN ('2020-09-02') ENGINE = MyISAM);
SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 'poms_status';