Should I design a table with a primary key of varchar or int?

后端 未结 13 1137
清酒与你
清酒与你 2020-11-27 13:45

I know this is subjective, but I\'d like to know peoples opinions and hopefully some best practices that I can apply when designing sql server table structures.

I pe

13条回答
  •  眼角桃花
    2020-11-27 14:35

    Keeping in mind that this is quite old a question, I still want to make the case for using varchar with surrogate keys fur future readers:

    1. An environment with several replicated machines
    2. Scenarios where it is required that the ID of a to be inserted row is known before it is actually inserted (i.e., the client assigns this ID, not the database)

提交回复
热议问题