如何查看mysql数据库的数据量

如何查看mysql数据库的数据量,第1张

documentonmouseup = function () {

documentonmouseup = null;

documentonmousemove = null;

直接在查询分析器运行即可:

declare @id int

declare @type character(2)

declare @pages

int

declare @dbname sysname

declare @dbsize dec(15,0)

declare @bytesperpage dec(15,0)

declare @pagesperMB dec(15,0)

create table #spt_space

(

objid int null,

rows int null,

reserved dec(15) null,

data dec(15) null,

indexp dec(15) null,

unused dec(15) null

)

set nocount on

-- Create a cursor to loop through the user tables

declare c_tables cursor for

select id

from sysobjects

where xtype = 'U'

open c_tables

fetch next from c_tables

into @id

while @@fetch_status = 0

begin

/ Code from sp_spaceused /

insert into #spt_space (objid, reserved)

select objid = @id, 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

where objid = @id

/ index: sum(used) where indid in (0, 1, 255) - data /

update #spt_space

set indexp = (select sum(used)

from sysindexes

where indid in (0, 1, 255)

and id = @id)

- data

where objid = @id

/ unused: sum(reserved) - sum(used) where indid in (0, 1, 255) /

update #spt_space

set unused = reserved

- (select sum(used)

from sysindexes

where indid in (0, 1, 255)

and id = @id)

where objid = @id

update #spt_space

set rows = irows

from sysindexes i

where iindid < 2

and iid = @id

and objid = @id

fetch next from c_tables

into @id

end

select TableName = (select left(name,60) from sysobjects where id = objid),

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

ReservedKB = ltrim(str(reserved dlow / 1024,15,0) + ' ' + 'KB'),

DataKB = ltrim(str(data dlow / 1024,15,0) + ' ' + 'KB'),

IndexSizeKB = ltrim(str(indexp dlow / 1024,15,0) + ' ' + 'KB'),

UnusedKB = ltrim(str(unused dlow / 1024,15,0) + ' ' + 'KB')

from #spt_space, masterdbospt_values d

where dnumber = 1

and dtype = 'E'

order by reserved desc

drop table #spt_space

close c_tables

deallocate c_tables

数据库存储最终也保存到文件里面。

mysql安装目录下面有一个myini文件,在这个文件里面搜索datadir

这行,其中datadir指向一个目录,这个目录是mysql数据库文件的存贮路径,然后你可以查看使用量了。

你可以用sp_spaceused

这个命令,如果想知道准确的使用量可以加上参数

@updateusage=ture

sp_spaceused

@updateusage='true'。

或者就右键看你数据库的属性,里面有数据文件的信息。在那里也可以对你的数据库做容量限制。

以上就是关于如何查看mysql数据库的数据量全部的内容,包括:如何查看mysql数据库的数据量、如何查看SQL2000数据库中所有表的数据量大小、怎么查看mysql数据库使用量等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9359474.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-27
下一篇 2023-04-27

发表评论

登录后才能评论

评论列表(0条)

保存