一页=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=页数
页头占去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