Re: Data TYPE Creation - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Data TYPE Creation
Date
Msg-id 20030317141751.GB19324@wolff.to
Whole thread Raw
In response to Data TYPE Creation  ("Guillaume Houssay" <ghoussay@noos.fr>)
Responses Re: Data TYPE Creation  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Mon, Mar 17, 2003 at 14:40:28 +0000,
  Houssay Guillaume <ghoussay@noos.fr> wrote:
> Thank you for your answer.
> By constraint you mean having the length of the INT2 field set to 1 ? I do not know how to define a constraint by
anotherway. 

create table example (col1 int check (col1 < 256 and col1 > 0));

This would only make sense if your data is really constrained this way.
The idea is to prevent invalid data from getting into the system, not to
save space.

>
> What about the disk space ? By defining an INT2 with a constraint of 1 byte, how much space will be used in the
memory(1 byte or 2 bytes). This is really one of my concern. 

The extra disc space won't be that much because there is other information
being stored besides that raw data. So that int2 won't take up twice as much
space as int1 (note postgres doesn't have that type).

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Data TYPE Creation
Next
From: Tom Lane
Date:
Subject: Re: Data TYPE Creation