boolean whetherExistsTableName( @Param("tableSchema") String tableSchema,@Param("tableName") String tableName);
<select id="whetherExistsTableName" parameterType="map" resultType="java.lang.Boolean"> SELECT (CASE WHEN count( * ) > 0 THEN TRUE ELSE FALSE END ) ex FROM information_schema.TABLES <where> <if test="tableSchema!=null and tableSchema!=''"> AND TABLE_SCHEMA = #{tableSchema} </if> <if test="tableName!=null and tableName!=''"> AND TABLE_NAME = #{tableName} </if> </where> </select>
其中:TABLE_SCHEMA 表示数据库名称,TABLE_NAME 表示表名称。
MYSQL CASE WHEN 用法链接:https://www.cnblogs.com/chenduzizhong/p/9590741.html