mybatis mysql获取当前数据库所有表与表字段信息

洛辰 6月前 ⋅ 189 阅读

mybatis mysql获取当前数据库所有表与表字段信息

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface TableDao {

    @Select("select * from information_schema.TABLES where TABLE_SCHEMA=(select database())")
    List<Map> listTable();

    @Select("select * from information_schema.COLUMNS where TABLE_SCHEMA = (select database()) and TABLE_NAME=#{tableName}")
    List<Map> listTableColumn(String tableName);
}

全部评论: 0

    我有话说: