mysql查询各数据库,数据表的容量大小,使用delete删除数据之后发现data_length存在缓存问题。解决办法使用 :TRUNCATE TABLE 表名;重新查询data_length发现数据已变化。
1.查看所有数据库容量大小
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;
2.查看所有数据库各表容量大小
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;
3.查看指定数据库容量大小
例:查看mysql库容量大小
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'
;
4.查看指定数据库各表容量大小
例:查看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;
Tags:
-
Gisele Creswick
2023-03-10 08:58:47
DataList2023.com presents all the new leads for you per country! Visit us on DataList2023.com
-
Arletha Macias
2023-02-23 14:06:41
Hello, MegaLeadsTree.com is shutting down. We have made available all our leads in 145 countries at a one-time fee. Visit us on MegaLeadsTree.com.
-
Dorris Dedman
2022-05-20 03:16:06
Your go-to source for leads. We can provide business to business and business to consumer leads, custom-tailored to your needs. CustomDatabases.org
-
Tobias Cabrera
2022-05-05 12:50:05
Hello, from CustomData.click we are a provider of unique databases that could help your business. Please visit us at CustomData.click to see if we can help you. Regards, Tobias
-
Lilla Carrington
2022-04-20 12:43:20
Hello. It is with sad regret to inform you TopDataList.com is shutting down. We have made all our databases available for you for a once off fee. Visit us on TopDataList.com
-
Raul Storkey
2022-04-15 04:33:44
ZippyLeads.org is running an easter special till the 18th of April. Get all the leads you need for your company with our easter special.
评论 (6)