Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

What Is Heap Table in SQL Server and How to Get All the Heap Table from a Database ? TIP # 54

DZone's Guide to

What Is Heap Table in SQL Server and How to Get All the Heap Table from a Database ? TIP # 54

· Java Zone
Free Resource

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

Heap table:-

A table without cluster index is called Heap table. Now you are thinking why we are talking about this.

So as SQL developer we should aware and In next post I will explain which is related to maintenance how to Rebuild a heap table.

Now our next question is how to determine all the heap table from a database

so below is simplest query to determine all the heap tables from a  database

SELECT T.Name ‘Heaptable’
FROM sys.indexes I 
  INNER JOIN sys.tables T
  ON I.object_id = T.object_id
WHERE I.type = 0 AND T.type = ‘U’

I ran this query on Adventureworks database and 2 tables with heap as shown in below figure

heaptable

now in next post we will discuss how to rebuild fragmented heap table which is a maintenance activity.

I hope this article may help you.

Thanks !!!

RJ!!


Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

Topics:

Published at DZone with permission of Rajat Jaiswal, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}