views:

122

answers:

6

is there a boolean type in oracle databases?

+7  A: 

Not at the SQL level and that's a pity There is one in PLSQL though

vc 74
+1  A: 

There is a boolean type for use in pl/sql, but none that can be used as the data type of a column.

klausbyskov
+1  A: 

A common space-saving trick is storing boolean values as an Oracle CHAR, rather than NUMBER:

Pranay Rana
CHAR(1) and VARCHAR2(1) are identical in space usage.
Tony Andrews
+4  A: 

Not only is the boolean datatype missing in Oracle's SQL (not PL/SQL), but they also have no clear recommendation about what to use instead. See this thread on asktom. From recommending CHAR(1) 'Y'/'N' they switch to NUMBER(1) 0/1 when someone points out that 'Y'/'N' depends on the English language, while e.g. German programmers might use 'J'/'N' instead.

The worst thing is that they defend this stupid decision just like they defend the ''=NULL stupidity.

ammoQ
1/0 is, if not ambiguous, at least less ambiguous.
Adam Musch
I also prefer 1/0, but of course you will also find people with a Visual Basic background who choose -1/0 instead. IMO there is only one sane solution to that problem: Oracle should create a boolean datatype. Can't be that hard when almost every other RDBMS has one.
ammoQ
But ''=NULL is false! '' IS NULL is true. :)
Jim Davis
+1  A: 

No there doesn't exist type boolean,but instead of this you can you 1/0(type number),or 'Y'/'N'(type char),or 'true'/'false' (type varchar2).

kupa
A: 

Just because nobody mentioned it yet: using RAW(1) also seems common practice.

Filburt