老熟女激烈的高潮_日韩一级黄色录像_亚洲1区2区3区视频_精品少妇一区二区三区在线播放_国产欧美日产久久_午夜福利精品导航凹凸

重慶分公司,新征程啟航

為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)

sybase數(shù)據(jù)庫怎么找出表大小腳本

這篇文章主要介紹“sybase數(shù)據(jù)庫怎么找出表大小腳本”,在日常操作中,相信很多人在sybase數(shù)據(jù)庫怎么找出表大小腳本問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”sybase數(shù)據(jù)庫怎么找出表大小腳本”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:主機域名、網(wǎng)絡(luò)空間、營銷軟件、網(wǎng)站建設(shè)、都昌網(wǎng)站維護、網(wǎng)站推廣。

以下SQL腳本用于找出表使用的空間大小,結(jié)果如圖

sybase數(shù)據(jù)庫怎么找出表大小腳本

腳本如下:

/*
** 使用方法:isql -U  -P   -w 10000 -x 30 -s '|' -SMBFE2 -i1.sql -o1.out
** 使用說明:此腳本僅在sybase15.5版本上做過測試,因環(huán)境不同,可能不適用
** 結(jié)果說明:其實就是sp_spaceused存儲過程的結(jié)果放在一個輸出,單位為MB
*/

use dbname
go

set nocount on  /*禁用行的顯示*/
go

/* 定義tab_name游標(biāo)為當(dāng)前用戶 用戶表表名結(jié)果集 */
declare tab_name cursor
for select name 
from sysobjects 
where type="U"
go
/* 打開游標(biāo) */
open tab_name
go

begin
	
	declare @objname sysname    /* table name */
	declare @empty_dpgs  int		/*
					** #empty data pages in hash region
					** of Virtually hashed table
					*/
	
	/* 創(chuàng)建臨時表:存放格式化后的結(jié)果 */
	create table #fmtpgcounts (
		name	char(35)
		,rowtotal	int
		,reserved	char(15)
		,data	char(15)
		,index_size	char(15)
		,unused	char(15)
	)


	fetch next from tab_name into @objname 		/* 讀取游標(biāo)的當(dāng)前值,并把賦值給變量@tabname */
	/* 循環(huán)條件:游標(biāo)從結(jié)果集中讀取完成時退出循環(huán) */
	while @@fetch_status = 0
    begin
		--print @objname
		--exec sp_spaceused @objname
		
		/*
		** Obtain the page count for the target object in the current
		** database and store them in the temp table #pagecounts.
		**
		** Note that we first retrieve the needed information from
		** sysindexes and we only then apply the OAM builtin system
		** functions on that data.  The reason being we want to relax
		** keeping the sh_int table lock on sysindexes for the duration
		** of the command.
		*/
		select name = o.name,
			tabid = i.id,
			iname = i.name, 
			indid = i.indid,
			low = d.low,
			rowtotal = convert(numeric(10,0), 0),
			reserved = convert(numeric(20, 9), 0),
			data = convert(numeric(20, 9), 0),
			index_size = convert(numeric(20, 9), 0),
			unused = convert(numeric(20, 9), 0)
		into #pagecounts 
		from sysobjects o, sysindexes i, master.dbo.spt_values d
				where i.id = object_id(@objname)
					/* 	--and i.indid = 0
				     0 = 表。
             1 = 所有頁鎖定表上的聚簇索引。
             >1 = DOL鎖定表上的非聚簇索引或聚簇索引。
             255 = text、 image、文本鏈或 Java 行外結(jié)構(gòu)(大對象,即LOB 結(jié)構(gòu))。
           */
					and o.id = i.id
					and d.number = 1
					and d.type = "E"
		
		/* perform the row counts */
		update #pagecounts
			set rowtotal = row_count(db_id(), tabid)
		where indid <= 1
		
		/* calculate the counts for indid > 1
		** case of indid = 1, 0 are special cases done later
		*/
		update #pagecounts set
			reserved = convert(numeric(20, 9),
			    reserved_pages(db_id(), tabid, indid)),
			index_size =  convert(numeric(20, 9),
			    data_pages(db_id(), tabid, indid)),
			unused = convert(numeric(20, 9),
				 ((reserved_pages(db_id(), tabid, indid) -
				  (data_pages(db_id(), tabid, indid)))))
		where indid > 1
		
		/* calculate for case where indid = 0 */
		update #pagecounts set
        reserved = convert(numeric(20, 9),
            reserved_pages(db_id(), tabid, indid)),
        data = convert(numeric(20, 9),
            data_pages(db_id(), tabid, indid)),
        unused = convert(numeric(20, 9),
                 ((reserved_pages(db_id(), tabid, indid) -
                  (data_pages(db_id(), tabid, indid)))))
    where indid = 0


		/* handle the case where indid = 1, since we need
		** to take care of the data and index pages. 
		*/
		update #pagecounts set
			reserved = convert(numeric(20, 9),
			             reserved_pages(db_id(), tabid, 0)) 
			          +  convert(numeric(20, 9),
			             reserved_pages(db_id(), tabid, indid)),
			index_size = convert(numeric(20, 9),
				     data_pages(db_id(), tabid, indid)),
		        data = convert(numeric(20, 9),
				       data_pages(db_id(), tabid, 0))
		where indid = 1

		/* calculate the unused count for indid = 1 case.*/
		update #pagecounts set
			unused = convert(numeric(20, 9), 
				     reserved - data - index_size)
		where indid = 1

	    /*
	    ** Check whether the table is Virtually hashed. For Virtually
	    ** Hashed tables, we maintain the number of empty pages in
    	    ** systabstats. Compute the #data pages and #unused pages
	    ** based on that value.
	    */
	    if(exists(select convert(char(30),a.char_value)
    		from sysattributes t, master.dbo.sysattributes c,
    			master.dbo.sysattributes a
    		where t.object_type = "T"
    			and t.object = object_id(@objname)
    			and c.class = 0 and c.attribute = 0
    			and a.class = 0 and a.attribute = 1
    			and t.class = c.object
    			and t.class = a.object
    			and t.attribute = a.object_info1
    			and a.char_value = 'hash key factors'))
    	    begin
    				select @empty_dpgs = emptypgcnt
    					from systabstats where id = object_id(@objname)
    	    end
      else
  	    begin
  				select @empty_dpgs = 0
  	    end

	    insert into #fmtpgcounts
	    select distinct name,
	    	rowtotal = convert(int, sum(rowtotal)),
    		reserved = convert(char(15), convert(varchar(11),
    		           convert(numeric(11, 0), sum(reserved) *
    			         (low / 1024) / 1024)) + " " + "MB"),
    		data = convert(char(15), convert(varchar(11),
    		       convert(numeric(11, 0), (sum(data) - @empty_dpgs) * 
    		       (low / 1024)  / 1024)) + " " + "MB"),
    		index_size = convert(char(15), convert(varchar(11),
    			     convert(numeric(11, 0), sum(index_size) *
    			     (low / 1024) / 1024)) + " " + "MB"),
    		unused = convert(char(15), convert(varchar(11),
    		    	 convert(numeric(11, 0), (sum(unused) + @empty_dpgs) *
    			     (low / 1024) / 1024)) + " " + "MB")
	        from #pagecounts

	    drop table #pagecounts     /* 刪除臨時表 #pagecounts */
    
		fetch next from tab_name into @objname
    end

  select distinct
    'TableName' = convert(char(35),name) ,
	  'RowTotal' = rowtotal ,
		'Reserved' = convert(char(10), reserved),
		'Data' = convert(char(10), data),
		'IndexSize' = convert(char(10), index_size),
		'Unused' = convert(char(10), unused)
			 from #fmtpgcounts
			     -- 去掉行數(shù)為0的行
			     where rowtotal <> 0
			     order by rowtotal desc

  --exec sp_autoformat #fmtpgcounts
	drop table #fmtpgcounts   /* 刪除臨時表 #fmtpgcounts */
end

go
/* 關(guān)閉游標(biāo) */
close tab_name
go
/* 釋放游標(biāo) */
deallocate tab_name
go

到此,關(guān)于“sybase數(shù)據(jù)庫怎么找出表大小腳本”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
分享文章:sybase數(shù)據(jù)庫怎么找出表大小腳本
當(dāng)前鏈接:http://www.xueling.net.cn/article/jedgji.html

其他資訊

在線咨詢
服務(wù)熱線
服務(wù)熱線:028-86922220
TOP
主站蜘蛛池模板: 操人视频| 欧美性猛交XXXX乱大交3 | 91激情在线 | 女人和拘做受全过程免费 | 国产欧美精品一区二区色综合 | 日本少妇色xxxxx中国免费看 | 男女做爰又黄又粗播放器 | 8x8x国产精品 | 久久无码人妻一区二区三区午夜 | 蜜臀av国内精品久久久夜夜快色 | 国产欧美性 | 久久6热最新地址 | 日日操夜夜操影院 | 欧美成人高清视频 | 老司机精品视频免费观看 | 国产精品无圣光一区二区 | 呦交小U女国产精品视频 | 精品精品国产毛片在线看 | 麻豆一区产品精品蜜桃的特点 | 国产真实交换配乱淫视频 | 圆产精品久久久久久久久久久 | 日本欧美v大码在线 | 国产一区二区h | 精品亚洲国产专区在线观看 | 久久久乱码精品亚洲日韩mv | 靠比久久| 麻豆一区产品精品蜜桃的特点 | 草莓视频做爰视频免费观看 | 国产成人久久精品77777的功能 | 午夜影视啪啪免费体验区入口 | 神马91 | 青草草色A免费观看在线 | 一区二区三级视频 | 大尺度露胸美女 | 国产50部艳色禁片无码 | 欧美一级成人 | 中国6一12呦女精品 蜜乳av一区二区三区 | 欧美国产福利 | 国产精品成人永久在线四虎 | 中文在线免费看视频 | 麻豆伊人|