Oracle SYS_GUID 不变

发布于 2024-07-15 04:32:40 字数 744 浏览 4 评论 0原文

我有一个 Oracle 项目,非常适合使用 GUID 作为密钥。 找到了以下代码片段

SET SERVEROUTPUT ON
BEGIN
FOR indx IN 1 .. 5
LOOP
DBMS_OUTPUT.put_line ( SYS_GUID );
END LOOP;
END;
/

我从 http://feuerthoughts .blogspot.com/2006/02/watch-out-for-sequential-oracle-guids.html

当我针对我的数据库运行它时(我在版本 10g 和版本 11 上尝试过),我得到的输出如下

64FE4083D6BA7CB4E0400F0A0E0A18B0
64FE4083D6BB7CB4E0400F0A0E0A18B0
64FE4083D6BC7CB4E0400F0A0E0A18B0
64FE4083D6BD7CB4E0400F0A0E0A18B0
64FE4083D6BE7CB4E0400F0A0E0A18B0

: 价值永远不会改变! 我需要做些什么才能将其设置为按预期工作吗?

编辑:我不是很善于观察 - GUID 正在变化,但看起来我遇到了上面链接所讨论的顺序 GUID 问题。

I have an Oracle project that would be a good fit for using GUIDs as a key. I found the following snippet

SET SERVEROUTPUT ON
BEGIN
FOR indx IN 1 .. 5
LOOP
DBMS_OUTPUT.put_line ( SYS_GUID );
END LOOP;
END;
/

From http://feuerthoughts.blogspot.com/2006/02/watch-out-for-sequential-oracle-guids.html

When I run it against my database (I tried it on versions 10g and version 11) I get output like

64FE4083D6BA7CB4E0400F0A0E0A18B0
64FE4083D6BB7CB4E0400F0A0E0A18B0
64FE4083D6BC7CB4E0400F0A0E0A18B0
64FE4083D6BD7CB4E0400F0A0E0A18B0
64FE4083D6BE7CB4E0400F0A0E0A18B0

I.e. the value never changes! Is there something I have to do to set this up to work as expected?

Edit: I am not very observant - the GUIDs are changing, but it looks like I am suffering from the sequential GUID problem that the link above is talking about.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

庆幸我还是我 2024-07-22 04:32:40

看起来还可以。 从描述来看:

SYS_GUID 生成并返回
全局唯一标识符(RAW值)
由16个字节组成。 在大多数
平台,生成的标识符
由主机标识符、
进程或线程的标识符
进程或线程调用
函数和非重复
该进程的(字节序列)
或线程。

从您的示例来看:

64FE4083D6BA7CB4E0400F0A0E0A18B0
64FE4083D6BB7CB4E0400F0A0E0A18B0
64FE4083D6BC7CB4E0400F0A0E0A18B0
64FE4083D6BD7CB4E0400F0A0E0A18B0
64FE4083D6BE7CB4E0400F0A0E0A18B0

没有人提到有关这些 GUID 值的分布的任何内容。 它们应该是不重复的,而且确实如此。 除非你每次都得到完全相同的输出。

Seems OK. From the description:

SYS_GUID generates and returns a
globally unique identifier (RAW value)
made up of 16 bytes. On most
platforms, the generated identifier
consists of a host identifier, a
process or thread identifier of the
process or thread invoking the
function, and a nonrepeating value
(sequence of bytes) for that process
or thread.

From your example:

64FE4083D6BA7CB4E0400F0A0E0A18B0
64FE4083D6BB7CB4E0400F0A0E0A18B0
64FE4083D6BC7CB4E0400F0A0E0A18B0
64FE4083D6BD7CB4E0400F0A0E0A18B0
64FE4083D6BE7CB4E0400F0A0E0A18B0

Nobody mentioned anything about the distribution of these GUID values. They should be nonrepeating and they are. Unless you get exactly the same output every time.

£噩梦荏苒 2024-07-22 04:32:40

值确实改变了......

           *
64FE4083D6BA7CB4E0400F0A0E0A18B0
64FE4083D6BB7CB4E0400F0A0E0A18B0
64FE4083D6BC7CB4E0400F0A0E0A18B0
64FE4083D6BD7CB4E0400F0A0E0A18B0
64FE4083D6BE7CB4E0400F0A0E0A18B0
           *

The value does change....

           *
64FE4083D6BA7CB4E0400F0A0E0A18B0
64FE4083D6BB7CB4E0400F0A0E0A18B0
64FE4083D6BC7CB4E0400F0A0E0A18B0
64FE4083D6BD7CB4E0400F0A0E0A18B0
64FE4083D6BE7CB4E0400F0A0E0A18B0
           *
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文