oracle、sql server数据库如何按表大小进行排序导出?
1、针对oracle数据库
用pl/sql之类的工具连接数据库(不要用查询分析器),执行如下sql语句,可以按表的大小排序,执行完成后可将结果导入到excel表格中
select owner, table_name, sum(size_m)
from (select s.owner,
s.segment_name as table_name,
(s.bytes / 1024 / 1024) as size_m
from dba_segments s, dba_tables t
where s.owner = t.owner
and s.segment_name = t.table_name
union
select s.owner,
l.table_name as table_name,
(s.bytes / 1024 / 1024) as size_m
from dba_segments s, dba_lobs l
where s.owner = l.owner
and s.segment_name = l.segment_name
union
select s.owner,
i.table_name as table_name,
(s.bytes / 1024 / 1024) as size_m
from dba_segments s, dba_indexes i
where s.owner = i.owner
and s.segment_name = i.index_name
union
select s.owner,
p.table_name as table_name,
(s.bytes / 1024 / 1024) as size_m
from dba_segments s, dba_tab_partitions p
where s.owner = p.table_owner
and s.segment_name = p.partition_name)
where owner not in ('SCOTT',
'ORACLE_OCM',
'OJVMSYS',
'SYSKM',
'XS$NULL',
'GSMCATUSER',
'MDDATA',
'SYSBACKUP',
'DIP',
'SYSDG',
'APEX_PUBLIC_USER',
'SPATIAL_CSW_ADMIN_USR',
'SPATIAL_WFS_ADMIN_USR',
'GSMUSER',
'AUDSYS',
'FLOWS_FILES',
'DVF',
'MDSYS',
'ORDSYS',
'DBSNMP',
'WMSYS',
'APEX_040200',
'APPQOSSYS',
'GSMADMIN_INTERNAL',
'ORDDATA',
'CTXSYS',
'ANONYMOUS',
'XDB',
'ORDPLUGINS',
'DVSYS',
'SI_INFORMTN_SCHEMA',
'OLAPSYS',
'LBACSYS',
'OUTLN',
'SYSTEM',
'SYS')
group by owner, table_name
order by sum(size_m) desc;
2、针对sql server数据库
先选中要查看的数据库(例如下图是eas85这个数据库),右键--报表(Reports)--标准报表(Standard Reports) --按排在前面的表的磁盘使用情况(Disk Usage by Top Tables)排序查询,查询需要一定的时间,查询完成后可以将结果导入的excel表格中
oracle、sql server数据库如何按表大小进行排序导出?
本文2024-09-22 20:28:03发表“eas cloud知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-eas-113809.html