Total Pageviews

2014/03/20

How to create a Boolean field in Oracle

Problem
If we would like to create a field, it will store the information if this datum had create by external system or be added by manual. 
Originally, I would like to crate a field with Boolean data type. But it seems that Oracle does not support Boolean data type.

Solution
We can use the check constraint to limit its value, i.e. 'Y' means adding by manual, 'N' means adding by external system.
ex.
ALTER TABLE FMS435FB ADD CONSTRAINT SELF_ADDED_CHECK CHECK (SELF_ADDED IN ('N',
                                                                           'Y'));


Reference
[1] http://www.techonthenet.com/oracle/check.php

No comments: