SELECT
table_schema AS database_name,
table_name
FROM
information_schema.tables
WHERE
table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
AND table_type ='BASE TABLE'
AND table_name NOT IN (
SELECT DISTINCT table_name
FROM information_schema.partitions
WHERE partition_name IS NOT NULL
)
ORDER BY
table_schema, table_name;
分区表
SELECT
p.table_schema AS database_name,
p.table_name,
GROUP_CONCAT(p.partition_name ORDER BY p.partition_ordinal_position) AS partitions,
p.partition_method,
p.partition_expression
FROM
information_schema.partitions p
WHERE
p.table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
AND p.partition_name IS NOT NULL
GROUP BY
p.table_schema, p.table_name, p.partition_method, p.partition_expression
ORDER BY
p.table_schema, p.table_name;
区分表
SELECT
t.table_schema AS database_name,
t.table_name,
CASE
WHEN p.table_name IS NULL THEN '普通表'
ELSE '分区表'
END AS table_type,
p.partition_method,
p.partition_expression
FROM
information_schema.tables t
LEFT JOIN (
SELECT DISTINCT
table_schema,
table_name,
partition_method,
partition_expression
FROM
information_schema.partitions
WHERE
partition_name IS NOT NULL
) p ON t.table_schema = p.table_schema AND t.table_name = p.table_name
WHERE
t.table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
AND t.table_type ='BASE TABLE'
ORDER BY
t.table_schema, t.table_name;
查出数据量
SELECT
t.table_schema AS '数据库名',
t.table_name AS '表名',
CASE
WHEN p.table_name IS NULL THEN '普通表'
ELSE CONCAT('分区表(', p.partition_method, ')')
END AS '表类型',
t.table_rows AS '数据行数(估算)',
CONCAT(ROUND(t.data_length / (1024 * 1024), 2), ' MB') AS '数据大小',
CONCAT(ROUND(t.index_length / (1024 * 1024), 2), ' MB') AS '索引大小',
CONCAT(ROUND((t.data_length + t.index_length) / (1024 * 1024), 2), ' MB') AS '总大小',
p.partition_expression AS '分区键'
FROM
information_schema.tables t
LEFT JOIN (
SELECT DISTINCT
table_schema,
table_name,
partition_method,
partition_expression
FROM
information_schema.partitions
WHERE
partition_name IS NOT NULL
) p ON t.table_schema = p.table_schema AND t.table_name = p.table_name
WHERE
t.table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
AND t.table_type ='BASE TABLE'
ORDER BY
t.table_schema,
CASE WHEN p.table_name IS NULL THEN 0 ELSE 1 END, -- 普通表在前
t.table_name;
SELECT
t.table_schema AS '数据库',
t.table_name AS '表名',
CASE
WHEN p.partition_method IS NULL THEN '普通表'
ELSE CONCAT('分区表(', p.partition_method, ')')
END AS '表类型',
t.table_rows AS '估算行数',
CONCAT(ROUND(t.data_length/1024/1024, 2), ' MB') AS '数据大小',
p.partition_expression AS '分区键'
FROM
information_schema.tables t
LEFT JOIN (
SELECT
table_schema,
table_name,
partition_method,
partition_expression
FROM
information_schema.partitions
WHERE
partition_name IS NOT NULL
GROUP BY
table_schema, table_name, partition_method, partition_expression
) p ON t.table_schema = p.table_schema AND t.table_name = p.table_name
WHERE
t.table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
AND t.table_type ='BASE TABLE'
ORDER BY
t.table_schema, t.table_name;
查出表行数
SELECT
t.table_schema AS '数据库',
t.table_name AS '表名',
CASE
WHEN p.partition_method IS NULL THEN '普通表'
ELSE CONCAT('分区表(', p.partition_method, ')')
END AS '表类型',
t.table_rows AS '估算行数',
p.partition_expression AS '分区键'
FROM
information_schema.tables t
LEFT JOIN (
SELECT DISTINCT
table_schema,
table_name,
partition_method,
partition_expression
FROM
information_schema.partitions
WHERE
partition_name IS NOT NULL
) p ON t.table_schema = p.table_schema AND t.table_name = p.table_name
WHERE
t.table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
AND t.table_type ='BASE TABLE'
ORDER BY
t.table_schema, t.table_name;
AI MCP 系列
AgentGPT-01-入门介绍
Browser-use 是连接你的AI代理与浏览器的最简单方式
AI MCP(大模型上下文)-01-入门介绍
AI MCP(大模型上下文)-02-awesome-mcp-servers 精选的 MCP 服务器
AI MCP(大模型上下文)-03-open webui 介绍 是一个可扩展、功能丰富且用户友好的…
1 题目: 单词搜索
官方标定难度:中
给定一个 m x n 二维字符网格 board 和一个字符串单词 word 。如果 word 存在于网格中,返回 true ;否则,返回 false 。
单词必须按照字母顺序,通过相邻的单元格内的字…
使用 Apache POI 操作 Excel文件,系列文章: 《SpringBoot整合POI实现Excel文件的导出与导入》 《SpringMVC实现文件的上传与下载》 《C#使用NPOI导出Excel文件》 《NPOI使用手册》 1、Apache POI 的介绍
Apache POI 是一个基于 Java 的开源库,专为读写 Microsoft Office 格…