Re: How to migrate column type from uuid to serial - Mailing list pgsql-general

From Peter J. Holzer
Subject Re: How to migrate column type from uuid to serial
Date
Msg-id 20201010093123.GC25239@hjp.at
Whole thread Raw
In response to Re: How to migrate column type from uuid to serial  (Hemil Ruparel <hemilruparel2002@gmail.com>)
Responses Re: How to migrate column type from uuid to serial  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
List pgsql-general
On 2020-10-07 20:10:34 +0530, Hemil Ruparel wrote:
> Sorry if this is silly but if it is a 128 bit number, why do we need 32
> characters to represent it? Isn't 8 bits one byte?

Yes, 8 bits are 1 byte. But that's 256 different values, so to display
them in 1 character you would need 256 different characters. That's not
possible in ASCII (ASCII has only 94 graphic characters), and even if
you included accented characters and other alphabets (like Greek or
Cyrillic) it would be hard to read. So the decision was to display each
byte as a pair of two hexadecimal digits (because 16 * 16 = 256). They
could also have used 3 decimal digits (000 - 255) for each byte, but
that would have wasted even more space, or they could have used base 32
or 64 for the whole number, but that would make conversion harder.

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment

pgsql-general by date:

Previous
From: Thorsten Schöning
Date:
Subject: Re: What's your experience with using Postgres in IoT-contexts?
Next
From: "Peter J. Holzer"
Date:
Subject: Re: What's your experience with using Postgres in IoT-contexts?