我可以使用GUID的第一个或最后16个字符,它仍然是唯一的?第一个、可以使用、字符、是唯一

2023-09-05 04:04:43 作者:静若安然

生成一个唯一的16个字符的关键,作为批次名称,这不需要任何类型的存储(例如独特的计数器)使用。

Generate a unique 16-character key, to use as a batch name, that doesn't require any type of storage (e.g. a unique counter).

我有一个运行Windows服务的每30秒。我拿起关闭的消息在MQ,并在间歇处理它们。其中的服务呼叫我在做现在需要16个字符的批次名称。 他们不在乎批次名称是什么,它只是需要在所有批次是唯一的。

I have a Windows service that runs every 30 seconds. I picks up messages off of an MQ and processes them in a batch. One of the service calls I'm making is requiring a 16-character batch name now. They don't care what the batch name is, it just needs to be unique across all batches.

如果我生成一个 的Guid ,我可以使用该字符串的第一个或最后16个字符,它仍然是唯一适合我的需要?

If I generate a Guid, can I use the first or last 16 characters of that string and it still be unique for my needs?

推荐答案

没有是简单的答案。为什么不使用的日期/时间?

No is the simple answer. Why not use the date/time?

例如,这里的一些Oracle生成的GUID

For example, here's some Oracle generated GUIDs

D71CDF38BB3B6026E0430A9A9A286026
D71CDF38BB3C6026E0430A9A9A286026
D71CDF38BB3D6026E0430A9A9A286026
D71CDF38BB3E6026E0430A9A9A286026
D71CDF38BB3F6026E0430A9A9A286026
D71CDF38BB406026E0430A9A9A286026