我对如何运行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获取表字段信息吗?

最佳答案

更改

desc #{tableName}
     ^




desc ${tableName}
     ^

关于java - Mybatis如何运行sql“desc表”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51232434/

10-13 02:42