Question : Contraint for 1 or 0

I created a number column to act as a Boolean data type.
How can I create a constraint  to only allow 0 or 1 ?

Answer : Contraint for 1 or 0

Easiest way is with a regular expression.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
drop table tab1 purge;
create table tab1 (
	col1 number,
	constraint col1_binary check (regexp_like(col1,'^[0-1]+$'))
);

insert into tab1 values(0);
insert into tab1 values(1);
insert into tab1 values(0101010101010101010);
insert into tab1 values(2);
Random Solutions  
 
programming4us programming4us