mybatis如何运行sql“desc table”

xggvc2p6  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(696)

我有一个关于如何运行sql“desc table”来获取表字段信息的问题。
我试图运行这些代码来获取表字段信息,但出现语法错误。

@Mapper
public interface TableMapper {

/**
 * 获取指定表中字段的具体信息
 * @param tableName 表名
 * @return 所有字段的具体信息.
 */
@Select("desc #{tableName}")
@Results({
        @Result(property = "fieldName", column = "Field", javaType = String.class),
        @Result(property = "fieldType", column = "Type", javaType = String.class),
        @Result(property = "nullable", column = "Null", javaType = String.class),
        @Result(property = "key", column = "Key", javaType = String.class),
        @Result(property = "extra", column = "Extra", javaType = String.class)
})
Set<TableFieldInfo> findTableFieldsInfo(@Param(value = "tableName") String tableName);}

有人能告诉我如何用mybaits获取表字段信息吗?

jfewjypa

jfewjypa1#

改变

desc #{tableName}
     ^

desc ${tableName}
     ^

相关问题