MYSQL容量照会
1442 ワード
1.すべてのデータベース容量の表示
2.すべてのデータベースの各テーブル容量のサイズを表示する
3.指定したデータベース容量の表示
例:mysqlライブラリ容量サイズの表示
4.指定したデータベースの各テーブル容量の表示
例: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
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;