MySQL、Oracle 查询所有表名和表行数

MySQL

需要选中information_schema库

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 like "%key%"  或者可筛选一下包含那个数据库之类的
order by table_rows desc;

Oracle

查询当前用户表sql

select t.table_name,t.num_rows from user_tables t ORDER BY t.num_rows DESC;

查询数据库所有的表sql

select t.table_name,t.num_rows from all_tables t ORDER BY t.num_rows DESC;

你可能感兴趣的:(应该没人会看,mysql,oracle,数据库)