| | |
| | | </choose>
|
| | | </foreach>
|
| | | FROM
|
| | | history h
|
| | | history_${yearAndMonthDay} h
|
| | | WHERE
|
| | | h.time >= #{start}
|
| | | AND h.time <![CDATA[<]]> #{end}
|
| | |
| | | <update id="deletePartition">
|
| | | ALTER table history drop PARTITION ${p};
|
| | | </update>
|
| | |
|
| | | <update id="createHistoryTable" parameterType="String">
|
| | | CREATE TABLE history_${yearMonthDay} (
|
| | | `mac` varchar(30) DEFAULT NULL,
|
| | | `value` json DEFAULT NULL,
|
| | | `time` datetime DEFAULT NULL,
|
| | | `version` int(11) DEFAULT NULL,
|
| | | KEY `_idx_mac_time` (`mac`,`time`) USING BTREE,
|
| | | KEY `_idx_mac` (`mac`) USING BTREE,
|
| | | KEY `_idx_time` (`time`) USING BTREE
|
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC
|
| | | </update>
|
| | |
|
| | | <delete id="dropHistoryTable" parameterType="String">
|
| | | drop table history_${yearMonthDay}
|
| | | </delete>
|
| | |
|
| | | <select id="selectLastDataByMac" resultType="com.moral.entity.History">
|
| | | select * from history_${yearMonthDay}
|
| | | where mac = #{mac}
|
| | | order by time desc
|
| | | limit 1
|
| | | </select>
|
| | | </mapper> |