布尔值给出无效的数据类型 - Oracle
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19518415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Boolean giving invalid datatype - Oracle
提问by rakeshisu
I am trying to create a table in Oracle SQL Developer but I am getting error ORA-00902.
我正在尝试在 Oracle SQL Developer 中创建一个表,但出现错误 ORA-00902。
Here is my schema for the table creation
这是我的表创建模式
CREATE TABLE APPOINTMENT(
Appointment NUMBER(8) NOT NULL,
PatientID NUMBER(8) NOT NULL,
DateOfVisit DATE NOT NULL,
PhysioName VARCHAR2(50) NOT NULL,
MassageOffered BOOLEAN NOT NULL, <-- the line giving the error -->
CONSTRAINT APPOINTMENT_PK PRIMARY KEY (Appointment)
);
What am I doing wrong?
我究竟做错了什么?
Thanks in advance
提前致谢
采纳答案by Rachcha
Oracle does not support the boolean
data type at schema level, though it is supported in PL/SQL blocks. By schema level, I mean you cannot create table columns with type as boolean
, nor nested table types of records with one of the columns as boolean
. You have that freedom in PL/SQL though, where you can create a record type collection with a boolean column.
Oracle 不支持boolean
模式级别的数据类型,但它在 PL/SQL 块中受支持。对于架构级别,我的意思是您不能创建类型为 as 的表列,也不能创建boolean
其中一列为 的记录的嵌套表类型boolean
。不过,您在 PL/SQL 中拥有这种自由,您可以在其中创建带有布尔列的记录类型集合。
As a workaround I would suggest use CHAR(1 byte)
type, as it will take just one byte to store your value, as opposed to two bytes for NUMBER
format. Read more about data types and sizes hereon Oracle Docs.
作为一种解决方法,我建议使用CHAR(1 byte)
类型,因为它只需要一个字节来存储您的值,而不是两个字节的NUMBER
格式。了解更多关于数据类型和大小这里在Oracle文档。
回答by rkh
Last I heard there were no boolean
type in oracle. Use number(1)
instead!
最后我听说boolean
oracle中没有类型。使用number(1)
,而不是!
回答by Filipe Silva
Oracle doesn't support boolean for table column datatype. You should probably use a CHAR(1) (Y/N)
Oracle 不支持表列数据类型的布尔值。您可能应该使用 CHAR(1) (Y/N)
You can see more info on this other answer
您可以查看有关此其他答案的更多信息
回答by Rachcha
i think u got a below good result
我想你得到了低于好的结果
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#CJACJGBG
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#CJACJGBG