<?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="com.market.mapper.KlineTableMapper">

    <!-- 查询 market 库中已存在的 futures_kline_* 表名 -->
    <select id="listKlineTables" resultType="java.lang.String">
        SELECT table_name
        FROM information_schema.tables
        WHERE table_schema = DATABASE()
          AND table_name LIKE 'futures_kline_%'
    </select>

    <!-- 以 kline_template 为模板建表（已存在时不报错） -->
    <update id="createTableLike">
        CREATE TABLE IF NOT EXISTS `${tableName}` LIKE `kline_template`
    </update>

</mapper>
