查看各个数据库表大小(不包含索引),以及表数据量
mysql:
select table_name,concat(round((DATA_LENGTH/1024/1024),2),'M')as size,table_rows from information_schema.tables order by table_rows desc limit 20
postgresql:
select table_schema,TABLE_NAME,reltuples,pg_size_pretty(pg_total_relation_size('"' || table_schema || '"."' || table_name || '"'))
from pg_class,information_schema.tables where relname=TABLE_NAME
ORDER BY reltuples desc limit 20
Sybase:
据空间大小的:
1.sybase(以16k逻辑页为例)
use YWST
go
select top 10 object_name(id) tabName,rowcnt rowCnt,convert(varchar,(pagecnt*16/1024)) + 'M' dataSize from systabstats order by rowcnt desc
oracle:
查记录条数可以用如下语句:
select * from user_tables t where t.NUM_ROWS is not null order by t.NUM_ROWS desc 。
表实际使用的空间:
select num_rows * avg_row_len
from user_tables