Re: How to migrate column type from uuid to serial

From: Thomas Kellerer <shammat(at)gmx(dot)net>
To:
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: How to migrate column type from uuid to serial
Date: 2020-10-07 14:50:07
Message-ID: 987d062d-dfcc-6954-f7b2-b895fcbd3783@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>> it is declared as uuid. But how does it occupy only 16 bytes?
>> Because a UUID is internally simply a 128bit number - the dashes you see are just formatting.

> Sorry if this is silly but if it is a 128 bit number, why do we need 32 characters to represent it?

The 36 (or 32 without the dashes) characters are just the default hex representation.

If you wanted to, you could convert it to a bigint (or a numeric).

See e.g. here for an example: https://stackoverflow.com/a/27286610

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hemil Ruparel 2020-10-07 14:53:58 Re: How to migrate column type from uuid to serial
Previous Message Stephen Frost 2020-10-07 14:41:01 Re: Handling time series data with PostgreSQL