Oracle SYS_GUID 不会改变

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/642055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 17:55:30  来源:igfitidea点击:

Oracle SYS_GUID does not change

oracleguid

提问by Greg Reynolds

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

我有一个非常适合使用 GUID 作为键的 Oracle 项目。我找到了以下片段

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

来自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

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

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.

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

回答by Anonymous

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 nonrepeatingvalue (sequence of bytes) for that process or thread.

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

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.

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

回答by cagcowboy

The value does change....

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

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