View the database capacity statement

The total size of all database queries

mysql> use information_schema;

mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES;

Statistical data amount of all the libraries (common)

Note: each table data amount = AVG_ROW_LENGTH * TABLE_ROWS + INDEX_LENGTH

 

SELECT

SUM(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)/1024/1024 AS total_mb

FROM information_schema.TABLES;

Size statistics for each library (common)

SELECT

table_schema,SUM(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)/1024/1024 AS total_mb

FROM information_schema.TABLES group by table_schema;

View the specified database (ORM libraries) size

mysql> use information_schema;

mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='ORM';

See all the capacity of each library size

select

table_schema as 'database'

sum (table_rows) as 'Recording',

sum (truncate (data_length / 1024/1024, 2)) as 'data capacity (MB)',

sum (truncate (index_length / 1024/1024, 2)) as 'Index Capacity (MB)'

from information_schema.tables

group by table_schema

order by sum(data_length) desc, sum(index_length) desc;

See all libraries the size of each table capacity

select

table_schema as 'database'

table_name as 'table name'

table_rows as 'record number'

truncate (data_length / 1024/1024, 2) as 'data capacity (MB)',

truncate (index_length / 1024/1024, 2) as 'Index Capacity (MB)'

from information_schema.tables

order by data_length desc, index_length desc;

Check the size of the specified storage capacity

select

table_schema as 'database'

sum (table_rows) as 'Recording',

sum (truncate (data_length / 1024/1024, 2)) as 'data capacity (MB)',

sum (truncate (index_length / 1024/1024, 2)) as 'Index Capacity (MB)'

from information_schema.tables

where table_schema='mysql';

Check the specified library tables capacity size

select

table_schema as 'database'

table_name as 'table name'

table_rows as 'record number'

truncate (data_length / 1024/1024, 2) as 'data capacity (MB)',

truncate (index_length / 1024/1024, 2) as 'Index Capacity (MB)'

from information_schema.tables

where table_schema='mysql'

order by data_length desc, index_length desc;

Guess you like

Origin www.cnblogs.com/kazihuo/p/12168156.html