Is there any boolean type in Oracle databases?

2019-01-03 12:56发布

Is there any Boolean type in Oracle databases, similar to the BIT datatype in Ms SQL Server?

10条回答
smile是对你的礼貌
2楼-- · 2019-01-03 13:03

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

查看更多
不美不萌又怎样
3楼-- · 2019-01-03 13:06

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.

查看更多
SAY GOODBYE
4楼-- · 2019-01-03 13:07

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

查看更多
啃猪蹄的小仙女
5楼-- · 2019-01-03 13:08

Nope.

Can use:

IS_COOL NUMBER(1,0)

1 - true
0 - false

--- enjoy Oracle

Or use char Y/N as described here

查看更多
男人必须洒脱
6楼-- · 2019-01-03 13:10

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

查看更多
混吃等死
7楼-- · 2019-01-03 13:14

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

查看更多
登录 后发表回答