当前位置:网站首页>MySQL & Oracle database capacity query

MySQL & Oracle database capacity query

2022-06-11 08:38:00 R.Jamin Cheng

1. View the capacity of all databases

select
table_schema as ‘ database ’,
sum(table_rows) as ‘ Record number ’,
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;

2. Check the capacity of all databases

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;

3. View the specified database capacity size

– example : see mysql Library capacity size
select
table_schema as ‘ database ’,
sum(table_rows) as ‘ Record number ’,
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’;

4. Check the capacity of each table in the specified database

– example : see mysql The capacity of each table in the library
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;

5. View the row size of the specified database table

– example : see Oracle Number of rows in the library table
SELECT TABLE_NAME,NUM_ROWS FROM ALL_TABLE WHEE OWNER = ‘LIUXM’
PS: Note the name of the owner , Case write

原网站

版权声明
本文为[R.Jamin Cheng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020508455904.html