sql中的boolean默认值 [英] boolean default in sql
问题描述
创建表格InfoBook
(
BID smallint主键,
BookID varchar(12)独一无二,
ISBN varchar(16)not null,
BookName varchar(50)not null,
AuthorName varchar(50)not null,
Publisher varchar(50)not null,
类别varchar(50)not null,
PublishYear char(4),
可用布尔值默认值true
);
当我运行此查询时收到以下错误
create table InfoBook
(
BID smallint primary key,
BookID varchar(12) unique,
ISBN varchar(16) not null,
BookName varchar(50) not null,
AuthorName varchar(50) not null,
Publisher varchar(50) not null,
Category varchar(50) not null,
PublishYear char(4),
Available boolean default true
);
when i run this query i receive the following error
Error at Command Line:23 Column:27
Error report:
SQL Error: ORA-00984: column not allowed here
00984. 00000 - column not allowed here
*Cause:
*Action:
Where did i go wrong?Please help me..Thanks
推荐答案
boolean类型是wronge
使用bit代替:
可用位默认值1
the "boolean" type is wronge
use "bit" instead :
Available bit default 1
请阅读本讨论
对不起,你可以那样做。 Oracle SQL中没有布尔数据类型。您可以在PL / SQL中使用BOOLEAN变量,但在SQL中不能使用BOOLEAN列。
使用NUMBER(1)(1表示true,0表示false )或VARCHAR2(1)('T'或'F')代替。
Sorry, you can't do that. There is no Boolean datatype in Oracle SQL. You can have BOOLEAN variables in PL/SQL, but not BOOLEAN columns in SQL.
Use NUMBER (1) (1 for "true" and 0 for "false") or VARCHAR2 (1) ('T' or 'F') instead.
来源:https://community.oracle.com/thread/2473001?tstart=0 [ ^ ]
这篇关于sql中的boolean默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!