我已经有了下面的查询来获取表的大小。然而,我只是为了获得有大小的前10名最大尺寸表。
怎么做?
select convert(varchar(30),o.name) AS table_name,
row_count(db_id(), o.id) AS row_count,
data_pages(db_id(), o.id, 0) AS pages,
data_pages(db_id(), o.id, 0) * (@@maxpagesize/1024) AS kbs
from sysobjects o
where type = 'U'
order by table_name
搜索类似的内容:select top 10 max(datapages) from sysobjects
编辑:
现在我还要获取索引的大小,在查询中添加sysindexes就足够了,还是应该像syscoments一样添加另一个系统表?
这样写它给我的顶级名称:
select top 10 convert(varchar(30),o.name) AS table_name,
row_count(db_id(), o.id) AS row_count,
data_pages(db_id(), o.id, 0) AS pages,
data_pages(db_id(), o.id, 0) * (@@maxpagesize/1024) AS kbs
from sysobjects o
where type = 'U'
order by table_name , kbs
这是抛出错误
select top 10 data_pages(db_id(), o.id, 0) * (@@maxpagesize/1024) AS kbs ,
convert(varchar(30),o.name) AS table_name,
row_count(db_id(), o.id) AS row_count,
data_pages(db_id(), o.id, 0) AS pages
from sysobjects o
where type = 'U'
order by kbs , table_name
答案 0 :(得分:1)
此查询适用于我的ASE 16.0系统:
fun toUpper(myChar) =
exception invalidCharacter;
if ord(myChar) >= ord(#"A") andalso ord(myChar) <= ord(#"Z") then myChar
else
if ord(myChar) >= ord(#"a") andalso ord(myChar) <= ord("z") then
chr(ord(myChar) - (ord(#"a") - ord(#"A")));
else raise invalidCharacter;