侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 143970 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

数据库数据量查询

2024-02-22 星期四 / 0 评论 / 0 点赞 / 3 阅读 / 1793 字

MysqlSELECT TABLE_NAME "表名",TABLE_ROWS "行数",DATA_LENGTH "大小",TABLE_COMMENT "说明" FROM INFORMATION_SC

Mysql

SELECT TABLE_NAME "表名",TABLE_ROWS "行数",DATA_LENGTH "大小",TABLE_COMMENT "说明"  FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '数据库名' ORDER BY TABLE_ROWS DESC

Sqlserver

create table #recordCount(name varchar(100),row varchar(100),reserved varchar(100),data varchar(100),index_size varchar(100),unused varchar(100))declare @name varchar(100)declare cur cursor  for    select name from sysobjects where xtype='u' order by nameopen curfetch next from cur into @namewhile @@fetch_status=0begin    insert into #recordCount    exec sp_spaceused   @name    print @name    fetch next from cur into @nameendclose curdeallocate curcreate table #recordCountNew(name varchar(100),row int,reserved int,data int,index_size int,unused int)insert into #recordCountNewselect name,convert(int,row) as row,convert(int,replace(reserved,'KB',''))*1024 as reserved,convert(int,replace(data,'KB',''))*1024 as data,convert(int,replace(index_size,'KB',''))*1024 as index_size,convert(int,replace(unused,'KB',''))*1024 as unused from #recordCountselect DISTINCT name '表名',row '行数',data '大小',index_size '索引大小' from #recordCountNew order by data descdrop table #recordCountdrop table #recordCountNew

Oracle

select b.owner,a.SEGMENT_NAME 表名,b.NUM_ROWS 行数,a.BYTES,b.LAST_ANALYZED 统计时间from  (    select segment_name,sum(Bytes) Bytes    from Dba_segments t    where t.segment_type='TABLE' or t.segment_type ='TABLE PARTITION'    group by segment_name  ) aleft join DBA_TABLES b on b.TABLE_NAME=a.SEGMENT_NAMEorder by a.BYTES desc;

广告 广告

评论区