Why disabling a clustered index makes the table inaccessible?

why isn't it possible to access the data directly from the table discarding the B-tree? (most likely by scanning the table row by row) wouldn't that be more appropriate than inaccessible data at all?

To answer your question, Indexing basics comes more handy -- An index is made up of a set of pages (index nodes) that are organized in a B-tree structure. This structure is hierarchical in nature, with the root node at the top of the hierarchy and the leaf nodes at the bottom. For more details refer here.

Also, as many people have described, Clustered Indexes == Original tables which are physically ordered with one or more keys or columns. So, when a clustered Index is disabled, its data rows cannot be accessed. You wont be able to Insert any data (for Non Clustered Index the Insert will succeed -- but that is not entirely related to this post -- as here the discussion is of Clustered Index) as well or neither Reorganize operation will work.

Below will explain you in detail :

we will use Adventureworks database to see the effect of disabling the CLUSTERED Index.

enter image description here

Now check the row count in the table:

enter image description here

Now disable the Clustered Index

enter image description here

Now select the row count from the table. This time it will error out with below message:

enter image description here

Even the reorganize operation does not work !!

enter image description here

Now rebuild the Clustered Index and it should work fine.

enter image description here

Select the table to see if we can access the data

enter image description here

So the bottom line is that, if we disable the Clustered Index, then Data in the table still exists, but will not be accessible for anything other than Drop or REBUILD operations. All related Non-clustered Indexes and views will be unavailable as well as Foreign Keys referencing the table will be disabled and there by leading the FAILURE for all the queries that are referencing the table.

Note: There is no option to ENABLE the Index. You have to REBUILD it.


The leaf level of the B+ tree is the table. What are you hoping to achieve by disabling the CI? Just don't do this if you don't want the data to be inaccessible.

I'm not really sure why SQL Server even allows you to do this.

CREATE TABLE T
(
    X INT CONSTRAINT PK PRIMARY KEY CLUSTERED, 
    Y INT CONSTRAINT UQ UNIQUE NONCLUSTERED
);

ALTER INDEX PK ON T DISABLE;

...also disables the NCI so even SELECT queries that would be covered by that are disabled. I can't think of any use case for this. - martin-smith

The only use I can think of off my head is exactly what is being discussed. Disabling a table. If you have a table that you don't want anyone touching, even dbo or sysadmin, then you can disable the clustered index. The table exists along with the data, but is completely inaccessible until you re-enable the clustered index. - kenneth-fisher