SQL Server newID - how is it created?

I would like to use newId to generate random numbers. Usually you will use it only once, but I could generate up to 10 random numbers on newId.

Is he random?

+3
source share
4 answers

Usually you use it only once, but I can generate up to 10 random numbers on newId. Is this random enough?

It depends on how you extract the numbers from newid. You cannot treat it as 128 independently random bits.

, 8 0 255, 8 .., , .

              v

E058D654-35A8-47F2-AE40-1C4EEBBDC549
01461481-ED8D-4B85-90FA-C08621D98DAE
AE861E4E-3469-4BDB-A38B-0031DACC8DAE
AF8905D0-E41B-4300-94F2-33BB45698CD1
003308A6-AE0A-4E20-9F24-047A6955E748
76F9B7ED-79AB-4EB1-B361-8C0AF5177CE3
B8F1CAC0-591D-436B-BB21-FAAD9EECA983
7FBEAEFD-2163-4315-A783-8106909E47D8
85E2FC60-E7B3-400F-B20A-CEFBECAEE4F9
17ED0A03-ADAD-4521-97EE-04815A867B32

              ^
              |
              always 4

, . , .

, RAND, . .

+2

, . GUID.

10 ? CHECKSUM(NEWID()), , , , ABS

+2

NewID GUID. .

+1

Accidentally for what? When you say you use it for generation, are you just going to use it for PNRG seed? I'm not sure if this is better than a timestamp for this. Or you are going to extract bits from a GUID - this is a bad idea.

http://www.random.org/randomness/

+1
source

Source: https://habr.com/ru/post/1746856/


All Articles