Oracle does not support BOOLEAN datatype in the table as shown in link
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i54330
If you create table with boolean dataype, you will get error.
SQL> CREATE TABLE t (Bool BOOLEAN);
CREATE TABLE t (Bool BOOLEAN)
*
ERROR at line 1:
ORA-00902: invalid datatype
But you can declare boolean variables in PL/SQL
DECLARE
bool BOOLEAN;
BEGIN
bool := TRUE;
IF x THEN
dbms_output.put_line('TRUE');
ELSIF NOT x THEN
dbms_output.put_line('FALSE');
END IF;
END;
/
If you really want to use boolean dataype in columns, there are 2 solutions.
The first one is use CHAR(1) with constraint/
CREATE TABLE t1 (Bool CHAR(1) CHECK (Bool IN ( 'Y', 'N' )));
Another common solution is to use number(1).
CREATE TABLE t2 (Bool number(1) CHECK (BOOL in (0,1)));

Post a Comment