schemata表:这个表里面主要是存储在Mysql中的所有的数据库的信息 tables表:这个表里存储了所有数据库中的表的信息,包括每个表有多少个列等信息。 columns表:这个表存储了所有表中的表字段信息。
schemata表:这个表里面主要是存储在Mysql中的所有的数据库的信息
tables表:这个表里存储了所有数据库中的表的信息,包括每个表有多少个列等信息。
columns表:这个表存储了所有表中的表字段信息。
statistics表:存储了表中索引的信息。
user_privileges表:存储了用户的权限信息。
schema_privileges表:存储了数据库权限。
table_privileges表:存储了表的权限。
column_privileges表:存储了列的权限信息。
character_sets表:存储了mysql可以用的字符集的信息。
collations表:提供各个字符集的对照信息。
collation_character_set_applicability表:相当于collations表和character_sets表的前两个字段的一个对比,记录了字符集之间的对照信息。
table_constraints表:这个表主要是用于记录表的描述存在约束的表和约束类型。
key_column_usage表:记录具有约束的列。
routines表:记录了存储过程和函数的信息,不包含自定义的过程或函数信息。
views表:记录了视图信息,需要有show view权限。
triggers表:存储了触发器的信息,需要有super权限。
select
table_schema as "数据库",
sum(table_rows) as "记录数",
sum(truncate(data_length/1024/1024, 2)) as "数据容量(MB)",
sum(truncate(index_length/1024/1024, 2)) as "索引容量(MB)"
from infORMation_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc
select
table_schema as "数据库",
table_name as "表名",
table_rows as "记录数",
truncate(data_length/1024/1024, 2) as "数据容量(MB)",
truncate(index_length/1024/1024, 2) as "索引容量(MB)"
from information_schema.tables
order by data_length desc, index_length desc;
select
table_schema as "数据库",
sum(table_rows) as "记录数",
sum(truncate(data_length/1024/1024, 2)) as "数据容量(MB)",
sum(truncate(index_length/1024/1024, 2)) as "索引容量(MB)"
from information_schema.tables
where table_schema="mysql"
select
table_schema as "数据库",
table_name as "表名",
table_rows as "记录数",
truncate(data_length/1024/1024, 2) as "数据容量(MB)",
truncate(index_length/1024/1024, 2) as "索引容量(MB)"
from information_schema.tables
where table_schema="mysql"
order by data_length desc, index_length desc;
select
TABLE_SCHEMA,
concat(truncate(sum(data_length)/1024/1024,2)," MB") as data_size,
concat(truncate(sum(index_length)/1024/1024,2)," MB") as index_size
from information_schema.tables
group by TABLE_SCHEMA
ORDER BY data_size desc;
select
TABLE_NAME,
concat(truncate(data_length/1024/1024,2)," MB") as data_size,
concat(truncate(index_length/1024/1024,2)," MB") as index_size
from information_schema.tables
where TABLE_SCHEMA = "查询的表名"
group by TABLE_NAME
order by data_length desc;
汇总学习使用,更多好的方法继续更新...
--结束END--
本文标题: MySQL查看数据库表容量大小和磁盘空间占用大小
本文链接: https://www.lsjlt.com/news/6928.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0