Is it possible to store a 1 byte number in Postgres?

后端 未结 7 1956
南方客
南方客 2021-02-04 00:26

I have 7 8-bit integer values per record that I want to store in Postgres. Pg doesn\'t offer a single byte integer type, SMALLINT, or 2 bytes, being the smallest integer datatyp

7条回答
  •  北海茫月
    2021-02-04 01:03

    There is pg_catalog.char ( another notation - "char" ) type which uses only 1 byte to store its value.

    select pg_column_size( 'A' );
    pg_column_size
    ----------------
                  2
    (1 row)
    
    select pg_column_size( 'A'::"char" );
    pg_column_size
    ----------------
                  1
    (1 row)
    

提交回复
热议问题