Do primary keys change when indexes are rebuilt or reorganized?

Posted on

Question :

I have a database containing tables that each have auto-increment int columns serving as the primary key column.

When I do a rebuild or reorganize operation on my indexes, does either operation potentially change the values of this column?

Does it matter if the indexes are ‘clustered’?

I’m using various versions of MS T-SQL from 2008 onward.

Answer :

No, they will not.

Rebuilding or reorganizing an index should never alter the underlying data itself, only its placement within database pages / extents.

However, as an aside have a read through this post – you might find that you don’t need to rebuild these indexes in the first place.

Leave a Reply

Your email address will not be published.