When having an identity column is not a good idea?

后端 未结 8 433
深忆病人
深忆病人 2021-01-12 04:06

In tables where you need only 1 column as the key, and values in that column can be integers, when you shouldn\'t use an identity field?

To the contrary, in

8条回答
  •  太阳男子
    2021-01-12 04:55

    You cannot (normally) specify values when inserting into identity columns, so for example if the column "id" was specified as an identify the following SQL would fail:

    INSERT INTO MyTable (id, name) VALUES (1, 'Smith')
    

    In order to perform this sort of insert you need to have IDENTITY_INSERT on for that table - this is not intended to be on normally and can only be on for a maximum of 1 tables in the database at any point in time.

提交回复
热议问题