Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Heap tables behaviour

$
0
0

Hi,

Can anyone explain the below behavior for HEAP tables? 

I have created a small heap table with 3 rows which can easily fit in 1 data page. Not sure why SQL Server is allocating 2 data pages. When I create a clustered index , I see only 1 data page which is expected. Not sure why 2 pages for Heaps ?


-- Heap table behaviour

CREATE TABLE Test
( c1 int IDENTITY(1,1) NOT NULL,
  c2  VARCHAR(2500)
)
GO

INSERT INTO Test( c2 ) SELECT REPLICATE('X', 2500)
GO 3
DBCC IND(0,N'Test',-1)
GO


-- Clusterred index behaviour
CREATE TABLE Test2
( c1 int IDENTITY(1,1) NOT NULL primary key,
  c2  VARCHAR(2500)
)
GO
INSERT INTO Test2( c2 ) SELECT REPLICATE('X', 2500)
GO 3
DBCC IND(0,N'Test2',-1)
GO

Thanks in Advance.



Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>