pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: stig erikson <stigerikson_nospam_@yahoo.se>
Cc: pgsql-sql@postgresql.org
Subject: Re: 1-byte integers
Date: 18 Sep 2004 11:39:01 -0400
Message-ID: <87oek3mvsa.fsf@stark.xeocode.com> (raw)
In-Reply-To: <ciflkp$pjh$1@news.hub.org>
References: <ciflkp$pjh$1@news.hub.org>


stig erikson <stigerikson_nospam_@yahoo.se> writes:

> how can i specify an integer to be one byte byte or even 4 bits long?
> int1, int(1), tinyint are nowhere to be seen.
> smallest i can find is smallint that is 2 bytes.

There's a type called "char" (the double quotes are needed). It's used by
postgres system catalogues but it's available for users too. It's a little
quirky since it has operators that treat it as a 1 byte text data type and
other operators that treat it as an integer data type. But that doesn't
normally lead to any problems, just strange symptoms when your code has a bug.

Other than that there are things like bit(4) which has a cast to and from
integer. But they won't save you any storage space. If you have multiple
columns like this and want to define a new type that aggregates them all for
storage but lets you access them individually that could be useful.

-- 
greg




view thread (2+ messages)

Message-ID: <87oek3mvsa.fsf@stark.xeocode.com>
Permalink:  ../87oek3mvsa.fsf@stark.xeocode.com/
Also on:    postgresql.org/message-id/87oek3mvsa.fsf@stark.xeocode.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gsstark@mit.edu, stigerikson_nospam_@yahoo.se
  Subject: Re: 1-byte integers
  In-Reply-To: <87oek3mvsa.fsf@stark.xeocode.com>

* 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