MySQL-特殊查询

查询表、列、数据

项目结构

在这里插入图片描述

代码

package com.hdb.bigdata.portal.pc.table.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hdb.bigdata.portal.pc.table.entity.BiKhFcbEmployeeIdcardNum;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

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

@Mapper
@Component
@DS("slave_4")
public interface BiKhFcbEmployeeIdcardNumMapper extends BaseMapper<BiKhFcbEmployeeIdcardNum> {

    @Select("select table_name from information_schema.tables where table_schema='bigdata_write'; ")
    List<Map<String, Object>> tableList();

    @Delete("TRUNCATE TABLE ${table};")
    Long empty(@Param("table") String table);

    @Select("SELECT COUNT(*) FROM ${table}")
    Long queryTotal(@Param("table") String table);

    @Select("SELECT * FROM  ${table} LIMIT #{startRowNum},#{pageSize};")
    List<Map<String, Object>> pageMaps(@Param("table") String table, @Param("startRowNum") Integer startRowNum, @Param("pageSize") Integer pageSize);

    @Select("select distinct column_name from information_schema.columns where table_name = #{table};")
    List<String> columns(@Param("table") String table);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值