略微加速

略速 - 互联网笔记

mysql 查询各个数据库大小、各个数据库表行数、指定数据表表行数

2021-02-05 leiting (1735阅读)

标签 MySql

1、查询各个数据库大小

-- 查询mysql各个数据库大小
SELECT
	table_schema,
		round(
			sum(data_length / 1024 / 1024),
			2
		) AS size, 'MB' as '单位'
FROM
	information_schema. TABLES
GROUP BY
	table_schema
ORDER BY
	size DESC;
  • 效果

2、指定数据库表行数

-- 查询mysql指定数据库表行数
SELECT
	table_name,
	table_rows
FROM
	information_schema.TABLES
WHERE
	TABLE_SCHEMA = 'your_db_name'
ORDER BY
	table_rows DESC;
  • 效果

3、各个数据库表行数

-- 查询mysql所有数据库中表行数
SELECT
	table_schema,
	table_name,
	table_rows
FROM
	information_schema. TABLES
ORDER BY
	table_schema,
	table_rows DESC;
  • 效果


北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3