When creating a table in DB2, to create a Boolean datatype column (since DB2 doesn’t have this natively) you have to use a check constraint on a smallint column. So if you have a column named “ACTIVE” that you want to be Boolean, you would create the that col like so:
ACTIVE SMALLINT NOT NULL,
CONSTRAINT CCACTIVE1 CHECK (ACTIVE in(0,1))
Then obviously, when you use that field, you can only insert/update using 1 and 0 respectively for your true and false values.
No comments:
Post a Comment