欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

sqlserver表大小,sql查看表的數(shù)據(jù)大小

如何查看SQLServer數(shù)據(jù)庫每個(gè)表占用的空間大小

創(chuàng)建存儲(chǔ)過程:

成都創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供禹州網(wǎng)站建設(shè)、禹州做網(wǎng)站、禹州網(wǎng)站設(shè)計(jì)、禹州網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、禹州企業(yè)網(wǎng)站模板建站服務(wù),10年禹州做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

CREATE PROCEDURE [dbo].[sys_viewTableSpace]

AS

BEGIN

SET NOCOUNT ON;

CREATE TABLE [dbo].#tableinfo(

表名 [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,

記錄數(shù) [int] NULL,

預(yù)留空間 [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,

使用空間 [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,

索引占用空間 [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,

未用空間 [varchar](50) COLLATE Chinese_PRC_CI_AS NULL

)

insert into #tableinfo(表名, 記錄數(shù), 預(yù)留空間, 使用空間, 索引占用空間, 未用空間)

exec sp_MSforeachtable "exec sp_spaceused '?'"

select * from #tableinfo

order by 記錄數(shù) desc

drop table #tableinfo

END

使用的時(shí)候直接 :exec sys_viewtablespace

SQLServer表的大小與表占硬盤空間大小有什么區(qū)別,應(yīng)該怎么去查這兩項(xiàng)性能?

表的大小一般指表的行數(shù),占用硬盤空間大小就比較復(fù)雜了,可以有以下幾個(gè)參數(shù):

分配空間,數(shù)據(jù)占用空間及索引占用空間。

執(zhí)行

EXEC alltablecount

即可顯示當(dāng)前數(shù)據(jù)庫所有表資源占用情況。

執(zhí)行前,請(qǐng)前建立以下表,和兩個(gè)存儲(chǔ)過程:

1、先建立表:HY_SPACE

CREATE TABLE [HY_SPACE] (

[name] [nvarchar] (128) COLLATE Chinese_PRC_CI_AS NULL ,

[rows] [char] (11) COLLATE Chinese_PRC_CI_AS NULL ,

[reserved] [varchar] (18) COLLATE Chinese_PRC_CI_AS NULL ,

[data] [varchar] (18) COLLATE Chinese_PRC_CI_AS NULL ,

[index_size] [varchar] (18) COLLATE Chinese_PRC_CI_AS NULL ,

[unused] [varchar] (18) COLLATE Chinese_PRC_CI_AS NULL

) ON [PRIMARY]

GO

2、建立統(tǒng)計(jì)存儲(chǔ)過程:

create procedure HYspaceused

@objname nvarchar(776) = null,

@updateusage varchar(5) = false

as

declare @idint

declare @typecharacter(2)

declare@pagesint

declare @dbname sysname

declare @dbsize dec(15,0)

declare @logsize dec(15)

declare @bytesperpagedec(15,0)

declare @pagesperMBdec(15,0)

create table #spt_space

(

rowsint null,

reserveddec(15) null,

datadec(15) null,

indexpdec(15) null,

unuseddec(15) null

)

if @updateusage is not null

begin

select @updateusage=lower(@updateusage)

if @updateusage not in ('true','false')

begin

raiserror(15143,-1,-1,@updateusage)

return(1)

end

end

if @objname IS NOT NULL

begin

select @dbname = parsename(@objname, 3)

if @dbname is not null and @dbname db_name()

begin

raiserror(15250,-1,-1)

return (1)

end

if @dbname is null

select @dbname = db_name()

select @id = null

select @id = id, @type = xtype

from sysobjects

where id = object_id(@objname)

if @id is null

begin

raiserror(15009,-1,-1,@objname,@dbname)

return (1)

end

if not exists (select * from sysindexes

where @id = id and indid 2)

if @type in ('P ','D ','R ','TR','C ','RF')

begin

raiserror(15234,-1,-1)

return (1)

end

else if @type = 'V '

begin

raiserror(15235,-1,-1)

return (1)

end

else if @type in ('PK','UQ')

begin

raiserror(15064,-1,-1)

return (1)

end

else if @type = 'F '

begin

raiserror(15275,-1,-1)

return (1)

end

end

if @updateusage = 'true'

begin

if @objname is null

dbcc updateusage(0) with no_infomsgs

else

dbcc updateusage(0,@objname) with no_infomsgs

print ' '

end

set nocount on

if @id is null

begin

select @dbsize = sum(convert(dec(15),size))

from dbo.sysfiles

where (status 64 = 0)

select @logsize = sum(convert(dec(15),size))

from dbo.sysfiles

where (status 64 0)

select @bytesperpage = low

from master.dbo.spt_values

where number = 1

and type = 'E'

select @pagesperMB = 1048576 / @bytesperpage

select database_name = db_name(),

database_size =

ltrim(str((@dbsize + @logsize) / @pagesperMB,15,2) + ' MB'),

'unallocated space' =

ltrim(str((@dbsize -

(select sum(convert(dec(15),reserved))

from sysindexes

where indid in (0, 1, 255)

)) / @pagesperMB,15,2)+ ' MB')

print ' '

insert into #spt_space (reserved)

select sum(convert(dec(15),reserved))

from sysindexes

where indid in (0, 1, 255)

select @pages = sum(convert(dec(15),dpages))

from sysindexes

where indid 2

select @pages = @pages + isnull(sum(convert(dec(15),used)), 0)

from sysindexes

where indid = 255

update #spt_space

set data = @pages

update #spt_space

set indexp = (select sum(convert(dec(15),used))

from sysindexes

where indid in (0, 1, 255))

- data

update #spt_space

set unused = reserved

- (select sum(convert(dec(15),used))

from sysindexes

where indid in (0, 1, 255))

select reserved = ltrim(str(reserved * d.low / 1024.,15,0) +

' ' + 'KB'),

data = ltrim(str(data * d.low / 1024.,15,0) +

' ' + 'KB'),

index_size = ltrim(str(indexp * d.low / 1024.,15,0) +

' ' + 'KB'),

unused = ltrim(str(unused * d.low / 1024.,15,0) +

' ' + 'KB')

from #spt_space, master.dbo.spt_values d

where d.number = 1

and d.type = 'E'

end

else

begin

insert into #spt_space (reserved)

select sum(reserved)

from sysindexes

where indid in (0, 1, 255)

and id = @id

select @pages = sum(dpages)

from sysindexes

where indid 2

and id = @id

select @pages = @pages + isnull(sum(used), 0)

from sysindexes

where indid = 255

and id = @id

update #spt_space

set data = @pages

update #spt_space

set indexp = (select sum(used)

from sysindexes

where indid in (0, 1, 255)

and id = @id)

- data

update #spt_space

set unused = reserved

- (select sum(used)

from sysindexes

where indid in (0, 1, 255)

and id = @id)

update #spt_space

set rows = i.rows

from sysindexes i

where i.indid 2

and i.id = @id

INSERT INTO HY_SPACE

select name = object_name(@id),

rows = convert(char(11), rows),

reserved = ltrim(str(reserved * d.low / 1024.,15,0) +

' ' + 'KB'),

data = ltrim(str(data * d.low / 1024.,15,0) +

' ' + 'KB'),

index_size = ltrim(str(indexp * d.low / 1024.,15,0) +

' ' + 'KB'),

unused = ltrim(str(unused * d.low / 1024.,15,0) +

' ' + 'KB')

from #spt_space, master.dbo.spt_values d

where d.number = 1

and d.type = 'E'

RETURN

end

return (0)

GO

3、主存儲(chǔ)過程

create procedure alltablecount as

declare @name varchar(100)

TRUNCATE TABLE HY_SPACE

declare tablecur cursor for select name from sysobjects where xtype= 'u '

create table #tablecount(tablename varchar(100),reccount int)

open tablecur

fetch next from tablecur into @name

while @@fetch_status!=-1

begin

exec ('insert into #tablecount select tablename='''+@name+''',reccount=count(1) from '+@name+' ')

EXEC HYspaceused @NAME

fetch next from tablecur into @name

end

close tablecur

deallocate tablecur

select * from #tablecount order by reccount desc

select * from HY_SPACE

GO

如何用sql語句查看某個(gè)數(shù)據(jù)庫中的表的大小

--讀取庫中的所有表名

select name from sysobjects where xtype='u'

--讀取指定表的所有列名

select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='表名')

獲取數(shù)據(jù)庫表名和字段

sqlserver中各個(gè)系統(tǒng)表的作用

sysaltfiles 主數(shù)據(jù)庫 保存數(shù)據(jù)庫的文件

syscharsets 主數(shù)據(jù)庫 字符集與排序順序

sysconfigures 主數(shù)據(jù)庫 配置選項(xiàng)

syscurconfigs 主數(shù)據(jù)庫 當(dāng)前配置選項(xiàng)

sysdatabases 主數(shù)據(jù)庫 服務(wù)器中的數(shù)據(jù)庫

syslanguages 主數(shù)據(jù)庫 語言

syslogins 主數(shù)據(jù)庫 登陸帳號(hào)信息

sysoledbusers 主數(shù)據(jù)庫 鏈接服務(wù)器登陸信息

sysprocesses 主數(shù)據(jù)庫 進(jìn)程

sysremotelogins主數(shù)據(jù)庫 遠(yuǎn)程登錄帳號(hào)

syscolumns 每個(gè)數(shù)據(jù)庫 列

sysconstrains 每個(gè)數(shù)據(jù)庫 限制

sysfilegroups 每個(gè)數(shù)據(jù)庫 文件組

sysfiles 每個(gè)數(shù)據(jù)庫 文件

sysforeignkeys 每個(gè)數(shù)據(jù)庫 外部關(guān)鍵字

sysindexs 每個(gè)數(shù)據(jù)庫 索引

sysmenbers 每個(gè)數(shù)據(jù)庫 角色成員

sysobjects 每個(gè)數(shù)據(jù)庫 所有數(shù)據(jù)庫對(duì)象

syspermissions 每個(gè)數(shù)據(jù)庫 權(quán)限

systypes 每個(gè)數(shù)據(jù)庫 用戶定義數(shù)據(jù)類型

select 列名=name from syscolumns where id=object_id(N'要查的表名')

sqlserver怎么看表的大小

select tabname as '表名',rowsNum as '表數(shù)據(jù)行數(shù)',reserved as '保留大小',data as '數(shù)據(jù)大小',index_size as '索引大小',unused_size as '未使用大小'

from #tabName

--where tabName not like 't%'

order by cast(rowsNum as int) desc

新聞標(biāo)題:sqlserver表大小,sql查看表的數(shù)據(jù)大小
轉(zhuǎn)載源于:http://aaarwkj.com/article38/dsspopp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、域名注冊(cè)虛擬主機(jī)、外貿(mào)網(wǎng)站建設(shè)移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)
蜜桃网站视频免费观看 | 国产黄色大片一级久久| 一区二区三区乱码国产| 国产高潮呻吟久久av| 少妇视频资源一区二区三区| 精品一区二区人妻乱交| 亚洲欧美日韩另类自拍| 久久好大好爽要死了欧美| 91亚洲婷婷国产综合精品| 日韩欧美中文字幕在线等| 日韩精品人妻一区二区网站| 毛片91成人在线播放| 午夜av在线毛片免费观看| 久久亚洲精品1区2区| 18岁未成年禁止观看视频| 一区二区三区国产不卡| 日本午夜福利久久久| 神马久久午夜免费福利| 国产91日韩欧美在线观看| 欧美日韩精品综合国产| 成人激情电影免费在线| 久久亚洲中文字幕精品一区四区| 国产精品欧美日韩精品| 亚洲欧洲日本一区精品| 蜜臀在线免费观看黄片视频| 日韩毛片免费看美日韩毛片| 欧美日韩性性在线观看| 小黄片视频免费在线播放| 亚洲国产午夜精品不卡| 亚洲av成人三区国产精品| 日韩av毛片在线观看| 日韩人妻高清精品专区| 国产日产亚洲欧美综合另类| 亚洲综合日韩丝袜人妻| 免费av在线网址网站| 色播婷婷午夜激情福利| 91美女人妻精品久久| 七月丁香色婷婷婷基地| 日产极品一区二区三区| 亚洲日本成人av在线观看| 尤物资源视频在线观看|