sql中的boolean默认值 [英] boolean default in sql

查看:1032
本文介绍了sql中的boolean默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建表格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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆