72 lines
2.4 KiB
XML
72 lines
2.4 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineSuperTableMapper">
|
|
|
|
<!-- 创建超级表 -->
|
|
<update id="createSuperTable">
|
|
CREATE STABLE IF NOT EXISTS ${dataBaseName}.${superTableName}
|
|
<foreach item="item" collection="columns" separator=","
|
|
open="(" close=")">
|
|
${item.fieldName} ${item.dataType}
|
|
<if test="item.dataLength > 0">
|
|
(${item.dataLength})
|
|
</if>
|
|
</foreach>
|
|
TAGS
|
|
<foreach item="item" collection="tags" separator=","
|
|
open="(" close=")">
|
|
${item.fieldName} ${item.dataType}
|
|
<if test="item.dataLength > 0">
|
|
(${item.dataLength})
|
|
</if>
|
|
</foreach>
|
|
</update>
|
|
|
|
<!-- 查看超级表 -->
|
|
<select id="showSuperTables" resultType="java.util.Map">
|
|
SHOW ${dataBaseName}.STABLES LIKE '${superTableName}'
|
|
</select>
|
|
|
|
<!-- 描述超级表结构 -->
|
|
<select id="describeSuperTable" resultType="java.util.Map">
|
|
DESCRIBE ${dataBaseName}.${superTableName}
|
|
</select>
|
|
|
|
<!-- 为超级表添加列 -->
|
|
<update id="addColumnForSuperTable">
|
|
ALTER STABLE ${dataBaseName}.${superTableName} ADD COLUMN ${column.fieldName} ${column.dataType}
|
|
<if test="column.dataLength > 0">
|
|
(${column.dataLength})
|
|
</if>
|
|
</update>
|
|
|
|
<!-- 为超级表删除列 -->
|
|
<update id="dropColumnForSuperTable">
|
|
ALTER STABLE ${dataBaseName}.${superTableName} DROP COLUMN ${column.fieldName}
|
|
</update>
|
|
|
|
<!-- 修改列宽 -->
|
|
<update id="modifyColumnWidthForSuperTable">
|
|
ALTER STABLE ${dataBaseName}.${superTableName} MODIFY COLUMN ${column.fieldName} ${column.dataType}
|
|
<if test="column.dataLength > 0">
|
|
(${column.dataLength})
|
|
</if>
|
|
</update>
|
|
|
|
<!-- 为超级表添加标签 -->
|
|
<update id="addTagForSuperTable">
|
|
ALTER STABLE ${dataBaseName}.${superTableName} ADD TAG ${tag.fieldName} ${tag.dataType}
|
|
<if test="tag.dataLength > 0">
|
|
(${tag.dataLength})
|
|
</if>
|
|
</update>
|
|
|
|
<!-- 为超级表删除标签 -->
|
|
<update id="dropTagForSuperTable">
|
|
ALTER STABLE ${dataBaseName}.${superTableName} DROP TAG ${tag.fieldName}
|
|
</update>
|
|
|
|
</mapper>
|