Oracle's lack of a Bit datatype for table columns

后端 未结 9 1005
醉酒成梦
醉酒成梦 2021-02-05 03:13

Oracle does not support a bit datatype or any other type for true/false scenarios. Does one use the char(1) field instead by using a specific letter to

9条回答
  •  你的背包
    2021-02-05 04:18

    The question is old but until the latest release of oracle is used it is still a valid question.

    I would solve the problem this way: Create a table which holds the possible values for true/false plus localized display text f.e. T$KEYWORDS ITEMNO ITEMTEXT ITEMTEXT_DE ITEMTEXT_FE ... 0 False Falsch 1 True Wahr

    Instead of True/False this could be also Selected, Not Selected, etc.

    And then add a foreigh key to your column to this table. That way you have only valid values and they do not change with localization.

    ANother good solution imho is using a check constraint on your data column. This ofc does not work if your values could be different in the same database/column depending on localization of clients.

    alter table tblLocations add flag number CONSTRAINT CHECK (flag IN (1,0));

提交回复
热议问题