Should all database tables have a primary key?

前端 未结 7 1541
旧巷少年郎
旧巷少年郎 2021-01-04 22:35

Is it good practice to give every database table a primary key? It seems to me that if the primary key is not explicitly needed, then it would just be extra clutter in my d

7条回答
  •  旧巷少年郎
    2021-01-04 23:12

    I have a table that is partitioned by CreateDate which is not unique. In my case I have decided to remove the primary key from this table because the fact that a primary key index must be unique meant that I couldn't make this index a LOCAL index, instead it has to be GLOBAL. This would have meant that any deletion from that table (amongst other actions) would have made this primary key index unusable, rendering it useless.

提交回复
热议问题