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