<?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.hccake.ballcat.codegen.database.mysql.MysqlTableInfoMapper">
    <select id="selectByPage" resultType="com.hccake.ballcat.codegen.model.bo.TableInfo">
        SELECT
            `table_name`,
            engine,
            table_comment,
            create_time
        FROM
            information_schema.TABLES
        WHERE
             table_schema = ( SELECT DATABASE ( ) )
        <if test="tableName != null and tableName.trim() != ''">
            AND `table_name` LIKE concat('%', #{tableName}, '%')
        </if>
        ORDER BY
        create_time DESC
    </select>


	<select id="queryTableInfo" resultType="com.hccake.ballcat.codegen.model.bo.TableInfo">
		SELECT
		`table_name`,
		engine,
		table_comment,
		create_time
		FROM
		information_schema.TABLES
		WHERE
		table_schema = ( SELECT DATABASE ( ) )
		AND `table_name` = #{tableName}
	</select>


	<select id="listColumnInfo" resultType="com.hccake.ballcat.codegen.model.bo.ColumnInfo">
        SELECT
            column_name,
            data_type,
            column_comment,
            column_key,
            extra,
            is_nullable,
            column_type
        FROM
            information_schema.COLUMNS
        WHERE
            table_name = #{tableName}
            AND table_schema = ( SELECT DATABASE ( ) )
        ORDER BY
            ordinal_position
	</select>


</mapper>
