Boolean giving invalid datatype - Oracle

匿名 (未验证) 提交于 2019-12-03 02:23:02

问题:

I am trying to create a table in Oracle SQL Developer but I am getting error 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

回答1:

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.

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 here on Oracle Docs.



回答2:

Last I heard there were no boolean type in oracle. Use number(1) instead!



回答3:

Oracle doesn't support boolean for table column datatype. You should probably use a CHAR(1) (Y/N)

You can see more info on this other answer



回答4:

i think u got a below good result

http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#CJACJGBG



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!