为什么数据库有一个奇怪的字母数字键

Why does a database have a weird alphanumeric key

我正在尝试连接两个数据库中的数据,这两个数据库都是由不同的 UI 应用程序自动创建的。其中,所有键都采用这种格式 "D8FC23D7-97D6-42F5-A52F-1CE93087B3A4"。

这样做有什么理由吗?我还看到了在 GIS 数据库中看起来相似的键。我不知道这些是否应该是一些计算出的密钥,也许是为了检测我正在尝试做什么,或者只是出于其他目的而随机。

PS 我正在使用 SQL 服务器。据我所知,这不是 SQL 服务器自动生成的东西。

这是一个GUID,也叫UUID,一个全球唯一的标识符(赋予,例如wikipedia or rfc4122)。 guid 背后的想法是应用程序可以生成全局唯一的标识符,而不需要中央单元进行任何编排(参见下面 rfc4122 的动机)。

各种系统、数据库和编程语言都提供了生成 UUID 的功能(例如 SELECT NEWID() 在 sql 服务器中);好处是使用 UUID 生成器,应用程序可以以自给自足的方式生成全局标识的单元。

UUID 可以用作数据库键,但在大多数情况下,您会发现更轻量级和更合适的键。

One of the main reasons for using UUIDs is that no centralized
authority is required to administer them (although one format uses
IEEE 802 node identifiers, others do not). As a result, generation
on demand can be completely automated, and used for a variety of
purposes. The UUID generation algorithm described here supports very high allocation rates of up to 10 million per second per machine if
necessary, so that they could even be used as transaction IDs.

UUIDs are of a fixed size (128 bits) which is reasonably small
compared to other alternatives. This lends itself well to sorting,
ordering, and hashing of all sorts, storing in databases, simple
allocation, and ease of programming in general.

Since UUIDs are unique and persistent, they make excellent Uniform Resource Names. The unique ability to generate a new UUID without a
registration process allows for UUIDs to be one of the URNs with the
lowest minting cost.