pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <shammat@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: How to migrate column type from uuid to serial
Date: Wed, 7 Oct 2020 16:50:07 +0200
Message-ID: <987d062d-dfcc-6954-f7b2-b895fcbd3783@gmx.net> (raw)
In-Reply-To: <CANW1aT_DQq5-cBL+1MCbd=hncUwJ3QWk-NWoVpwFxj=RR20hUg@mail.gmail.com>
References: <CANW1aT8fpZqpr6WcN1oj8-0PWjsgorPMEUQguUpO00E=bXYG2A@mail.gmail.com>
	<e06aab47-151c-ea50-36bf-a34d68337f22@aklaver.com>
	<CANW1aT9yDSB9DAC-LXvVU+UJK62oUFUBBjKKAvz+78ix2oEbCA@mail.gmail.com>
	<14155fce-965e-ae6b-256b-51df8e17e6e6@aklaver.com>
	<CANW1aT-ic-FFNcgsT6_uXn=SC8WXr6EJ=r2Eg7_bpMfHHApyDw@mail.gmail.com>
	<6fe03b17-f1ff-81e8-4ed1-72eb29d8d51d@gmx.net>
	<CANW1aT9WTZ_BMSr_M+kvg-JQN1O2znMUXi88-huqR4fkwU7NVQ@mail.gmail.com>
	<9ea3ff13-d78b-b5ce-2619-72cb02522e90@gmx.net>
	<CANW1aT_DQq5-cBL+1MCbd=hncUwJ3QWk-NWoVpwFxj=RR20hUg@mail.gmail.com>

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






view thread (16+ messages)  latest in thread

Message-ID: <987d062d-dfcc-6954-f7b2-b895fcbd3783@gmx.net>
Permalink:  ../987d062d-dfcc-6954-f7b2-b895fcbd3783@gmx.net/
Also on:    postgresql.org/message-id/987d062d-dfcc-6954-f7b2-b895fcbd3783@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: shammat@gmx.net
  Subject: Re: How to migrate column type from uuid to serial
  In-Reply-To: <987d062d-dfcc-6954-f7b2-b895fcbd3783@gmx.net>
  References: <CANW1aT8fpZqpr6WcN1oj8-0PWjsgorPMEUQguUpO00E=bXYG2A@mail.gmail.com> <e06aab47-151c-ea50-36bf-a34d68337f22@aklaver.com> <CANW1aT9yDSB9DAC-LXvVU+UJK62oUFUBBjKKAvz+78ix2oEbCA@mail.gmail.com> <14155fce-965e-ae6b-256b-51df8e17e6e6@aklaver.com> <CANW1aT-ic-FFNcgsT6_uXn=SC8WXr6EJ=r2Eg7_bpMfHHApyDw@mail.gmail.com> <6fe03b17-f1ff-81e8-4ed1-72eb29d8d51d@gmx.net> <CANW1aT9WTZ_BMSr_M+kvg-JQN1O2znMUXi88-huqR4fkwU7NVQ@mail.gmail.com> <9ea3ff13-d78b-b5ce-2619-72cb02522e90@gmx.net> <CANW1aT_DQq5-cBL+1MCbd=hncUwJ3QWk-NWoVpwFxj=RR20hUg@mail.gmail.com> <987d062d-dfcc-6954-f7b2-b895fcbd3783@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox