Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle's lack of a Bit datatype for table columns

Tags:

boolean

oracle

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 denote yes / true regardless of culture specific issues?

Instead of char should it be Number(1,0) for this instead - 0 being considered false / no, anything else being interpreted as true / yes?

Is this viable?


Why does Oracle not support a simple boolean type?

like image 510
Martin Milan Avatar asked Mar 11 '10 15:03

Martin Milan


People also ask

Does Oracle have bit data type?

The BIT datatype is usually represented by NUMBER(1) in Oracle systems as it simplifies comparison operations, but you could also use CHAR(1). The TIMESTAMP datatype can be represented using the ORA_ROWSCN pseudo column in Oracle.

Which of the following data type Cannot be used in Oracle Forms?

However, Oracle internally converts such datatypes to Oracle datatypes. The IBM products SQL/DS and DB2 datatypes TIME, TIMESTAMP, GRAPHIC, VARGRAPHIC, and LONG VARGRAPHIC have no corresponding Oracle datatype, and cannot be used. The TIME and TIMESTAMP datatypes are subcomponents of the Oracle datatype DATE.


1 Answers

Use a CHAR(1), and a constraint to allow only 1 and 0.

...

col CHAR(1), CONSTRAINT cons_atable_col1 CHECK (col1 IN ('1','0')) 
like image 101
Samuel Avatar answered Oct 02 '22 23:10

Samuel