What is uuid ossp in postgres

I saw this in migration

enable_extension 'uuid-ossp'

As far as I know, uuid is a long unique string based on some RFCs and this allows db (in this case pg) to have a column type like uuid

my question is: why is this type of column needed, not just a row column? is it to replace a regular column with an integer id and instead indicate uuid as id?

Is there any advantage to using uuid since id instead of having a column of type string contains uuid?

+4
source share
2 answers

uuid type. UUID - . -

select 'a'::uuid;
ERROR:  invalid input syntax for uuid: "a"

-, . UUID 16 , 33:

select
    pg_column_size('0123456789abcdef0123456789abcdef'),
    pg_column_size('0123456789abcdef0123456789abcdef'::uuid)
;
 pg_column_size | pg_column_size 
----------------+----------------
             33 |             16

uuid-ossp uuid.

+3

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


All Articles