34,575
社区成员
发帖
与我相关
我的任务
分享
create table tb(id int identity(1,1),v varchar(10))
go
begin tran
insert tb select 'aa'
waitfor time '12:00'
rollback tran
select * from tb with(nolock)
select * from sys.indexes where object_id=object_id('tb')
go
/*
2073058421 NULL 0 0 HEAP 0 1 0 0 0 0 0 0 0 1 1
*/
select a.* from sys.system_internals_allocation_units a
inner join
sys.partitions b
on a.container_id = b.hobt_id
where object_id=object_id('tb')
/*
72057594043301888 1 IN_ROW_DATA 72057594038321152 1 2 2 1 0x590000000100 0x000000000000 0x6D0000000100
*/
go
dbcc traceon(3604)
go
dbcc extentinfo(aa,tb)
/*
1 89 1 1 2073058421 0 1 72057594038321152 In-row data 0x6100000000000000
*/
go
--不連續沒關係,需要時候生成一列
if object_id('tb')is not null drop table tb
go
create table tb(ID int )
insert tb select 1
insert tb select 2
insert tb select 5
insert tb select 18
insert tb select 13
select id ,[newid]=(select count(*) from tb where id<=t.id) from tb t order by [newid]
/*id newid
----------- -----------
1 1
2 2
5 3
13 4
18 5
(影響 5 個資料列)
*/