您好,我正在尝试在oracle sqlplus中创建表,但一直收到无效数据类型错误

cs7cruho  于 2023-03-17  发布在  Oracle
关注(0)|答案(2)|浏览(255)
SQL> CREATE TABLE Plays (    playId INT PRIMARY KEY,    gameId INT,    playNumber INT,    quarter INT,    time TIMESTAMP,    yardLine INT,    possessionTeam VARCHAR2(10),    playType VARCHAR2(10),    yardGain INT,    yardsToGo INT,    down INT,    distance INT,    yardsToEndzone INT,    scoreDiff INT,    epa REAL,    isRush BOOLEAN,    isPass BOOLEAN,    isIncomplete BOOLEAN,    isTouchdown BOOLEAN,    passType VARCHAR2(10),    passLocation VARCHAR2(10),    rushDirection VARCHAR2(10),    rushLocation VARCHAR2(10),    receiver VARCHAR2(20),    defender VARCHAR2(20));

创建桌面游戏(游戏ID INT主键,游戏ID INT,
游戏号码INT,四分之一INT,时间TIMESTAMP,码线INT,
拥有队VARCHAR 2(10),比赛类型VARCHAR 2(10),码数增益INT,前进码数INT,下降INT,距离INT,到终点区码数INT,得分差INT,epa真实的,是冲刺布尔值,是传球布尔值,是不完全布尔值,是触地布尔值,
通过类型VARCHAR 2(10)、通过位置VARCHAR 2(10)、紧急方向VARCHAR 2(10)、紧急位置VARCHAR 2(10)、接收方VARCHAR 2(20)、防御方VARCHAR 2(20))*
第1行错误:
ORA-00902:数据类型无效
尝试创建sql表,但得到了一个无效的数据类型错误,但从我的Angular 看,一切似乎都很好

kkih6yb8

kkih6yb81#

BOOLEAN不是有效的Oracle SQL数据类型。(它是PL/SQL中的有效数据类型。)
您可以使用不同的数据类型,如CHAR(1)NUMBER(1,0),并添加检查约束以将其限制为'Y'/'N'1/0

CREATE TABLE Plays (
    playId         INT PRIMARY KEY,
    gameId         INT,
    playNumber     INT,
    quarter        INT,
    time           TIMESTAMP,
    yardLine       INT,
    possessionTeam VARCHAR2(10),
    playType       VARCHAR2(10),
    yardGain       INT,
    yardsToGo      INT,
    down           INT,
    distance       INT,
    yardsToEndzone INT,
    scoreDiff      INT,
    epa            REAL,
    isRush         CHAR(1) CHECK (isRush IN ('Y', 'N')),
    isPass         CHAR(1) CHECK (isPass IN ('Y', 'N')),
    isIncomplete   CHAR(1) CHECK (isIncomplete IN ('Y', 'N')),
    isTouchdown    CHAR(1) CHECK (isTouchdown IN ('Y', 'N')),
    passType       VARCHAR2(10),
    passLocation   VARCHAR2(10),
    rushDirection  VARCHAR2(10),
    rushLocation   VARCHAR2(10),
    receiver       VARCHAR2(20),
    defender       VARCHAR2(20)
);

fiddle

txu3uszq

txu3uszq2#

在Oracle中,不能使用BOOLEAN数据类型。
有效的create语句如下所示:

CREATE TABLE Plays
(playId INT PRIMARY KEY,
 gameId INT,
 playNumber INT,
 quarter INT,
 time TIMESTAMP,
 yardLine INT,
 possessionTeam VARCHAR2(10),
 playType VARCHAR2(10),
 yardGain INT,
 yardsToGo INT,
 down INT,
 distance INT,
 yardsToEndzone INT,
 scoreDiff INT,
 epa REAL,
 isRush char(1),
 isPass char(1),
 isIncomplete char(1),
 isTouchdown char(1),
 passType VARCHAR2(10),
 passLocation VARCHAR2(10),
 rushDirection VARCHAR2(10),
 rushLocation VARCHAR2(10),
 receiver VARCHAR2(20),
 defender VARCHAR2(20));

相关问题