Identity Columns and Table Locks

In my “write less with more” presentation today at OUG Ireland 2016, I showed the ability to change an identity column from GENERATED BY DEFAULT AS IDENTITY to GENERATED ALWAYS AS IDENTITY with the START WITH LIMIT VALUE option. You can read about this option (and about identity columns in general) in detail in Write Less with More – Part 2.
Jonathan Lewis raised a good question – if the identity column is not indexed, will this operation lock the entire table?
I didn’t know the answer so I checked it later, and the answer is that is locks the entire table in exclusive mode.
And… this is true also if the identity column is indexed.

Leave a Reply

Your email address will not be published. Required fields are marked *