I am trying to create table in SQL Developer but I did not find the Boolean data type or bit data type.
我试图在SQL Developer中创建表,但我没有找到布尔数据类型或位数据类型。
Is their another type instead of these?
他们是另一种类型而不是这些吗?
1 个解决方案
#1
1
Oracle doesn't support a Boolean datatype
for columns. A common work-around is VARCHAR2(1)
or char
with a constraint to permit only 'Y' and 'N'' as values.
Oracle不支持列的布尔数据类型。一个常见的解决方法是VARCHAR2(1)或带有约束的char,只允许'Y'和'N'作为值。
if you want to create table with bool column, here the sample syntax
如果你想用bool列创建表,这里是示例语法
create table boolTable (
bool char check (bool in ('N','Y')
));
insert into boolTable values('Y'); -- This query insert value
`insert into boolTable values(1);` -- This query going to fail.
#1
1
Oracle doesn't support a Boolean datatype
for columns. A common work-around is VARCHAR2(1)
or char
with a constraint to permit only 'Y' and 'N'' as values.
Oracle不支持列的布尔数据类型。一个常见的解决方法是VARCHAR2(1)或带有约束的char,只允许'Y'和'N'作为值。
if you want to create table with bool column, here the sample syntax
如果你想用bool列创建表,这里是示例语法
create table boolTable (
bool char check (bool in ('N','Y')
));
insert into boolTable values('Y'); -- This query insert value
`insert into boolTable values(1);` -- This query going to fail.