RE: Problum Data type : Boolean on Informix
Posted in 1998
----------
From: Vira Ngramluxsameekhae[SMTP:ViraN@tac.co.th]
Sent: Wednesday, February 04, 1998 2:45 AM
Informix don't have boolean data type.
JL: IUS does have a boolean data type, with constants T and F or 1 and 0.
thus I have used dec(1) or char(1) in place of it .
JL: OK. Both work.
I know that size of dec(1) = 2 bytes and size of char(1) = 1 bytes
which data type I should use and why.
JL: Whichever works best for you. I'd use CHAR(1) with a CHECK constraint:
CREATE TABLE WhatEver
(
...
BoolCol CHAR(1) DEFAULT 'F' NOT NULL
CHECK (BoolCol IN ('T', 'F')) CONSTRAINT we_boolcol1,
...
);
This will be simplest to upgrade when you migrate to IUS or any other system with a boolean data type.
If you want to allow '0' and '1' (for False and True respectively) instead, then that would work too; I'd
still use a CHAR(1) column rather than a DEC(1) column, not only because the storage is smaller but
also because the logic is (in my view) simpler. Your mileage may vary!
Yours,
Jonathan Leffler (jleffler@visa.com) #include <bother.ms-exchange.h>