sql数据库磁盘空间计算

一页=8KB
页头占去96字节
stuid(int) stuname(char(10)),stusex(char(10)),classID(int)
行占字节数 4+10+10+4+9=37
每一页存储多少行(8*1024-96)/37=218
需要多少页 100000(总数据行数)/218=页数

页数*8KB/2014=实际的磁盘空间

---计算数据库表占得页数
select OBJECT_NAME(i.object_id) as 表名,data_pages as 数据页数
from sys.indexes as i
join sys.partitions as p on p.object_id=i.object_id and p.index_id=i.index_id
join sys.allocation_units as a on a.container_id=p.partition_id
where i.object_id=object_id('stuinfo');


SELECT * FROM STUINFO;


DECLARE @count INT;
select @count=1;
while(@count<=100000)
begin
	INSERT INTO STUINFO (stuid,stuname,stusex,classID) VALUES (@count,'1111','男',1);
	select @count = @count+1;
end



select * from stuinfo where stuid=100000;

select count(*) from stuinfo;

select * from sysobjects where name= 'stuinfo';
select * from sysindexes where id=581577110;

select * from sysindexes

select * from stuinfo;

drop table stuinfo;

create table stuinfo 
(
	stuid int,
	stuname char(10),
	stusex char(10),
	classID int
)

declare @count int;
declare @stuid int;

select @count = 1;

while(@count<1000)
begin
select @stuid=cast(ceiling(rand() * 100000000) as int)
insert into stuinfo (stuid,stuname,stusex,classID) values (@stuid,'1111','男',1); 	
select @count = @count+1
end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值