为什么我们不能有多个主键? [英] Why we can't have more than one primary key?

查看:54
本文介绍了为什么我们不能有多个主键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道一个表中的主键不能超过 1 个,但技术原因是什么?

I Know there can't be more than 1 primary key in a table but what is the technical reason ?

推荐答案

直接从 SO:

您只能有一个主键,但主键中可以有多个列.

You can only have one primary key, but you can have multiple columns in your primary key.

您还可以在表上设置唯一索引,这有点像主键,因为它们会强制执行唯一值,并加快对这些值的查询.

You can also have Unique Indexes on your table, which will work a bit like a primary key in that they will enforce unique values, and will speed up querying of those values.

Primary 在 Primary 的上下文中Key 表示它的重要性排在第一位.因此,只能有一个键.顾名思义.

它通常也是索引附加了实际数据的键,即数据与主键索引一起存储.其他索引只包含被索引的数据,可能还有一些包含的列.

It's also usually the key for which the index has the actual data attached to it, that is, the data is stored with the primary key index. Other indices contain only the data that's being indexed, and perhaps some Included Columns.

这篇关于为什么我们不能有多个主键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆