Is there any Boolean type in Oracle databases, similar to the BIT
datatype in Ms SQL Server?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
There is a boolean type for use in pl/sql, but none that can be used as the data type of a column.
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 toNUMBER(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.Not at the SQL level and that's a pity There is one in PLSQL though
Nope.
Can use:
--- enjoy Oracle
Or use char Y/N as described here
A common space-saving trick is storing boolean values as an Oracle CHAR, rather than NUMBER:
Just because nobody mentioned it yet: using RAW(1) also seems common practice.