本文介绍了创建表-SQL错误:ORA-00905:缺少关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我我做错了什么?我尝试过更改一些事情,但是我一直遇到相同的错误,因此我确信自己已经忘记了一些东西.希望有人能帮忙

can anyone tell me what I've done wrong? I've tried changing a few things around but I keep getting the same error so I'm convinced that I've forgotten something. I hope someone can help

Error starting at line : 1 in command -


CREATE TABLE Player(
Plyr_ID int NOT NULL PRIMARY KEY,
Plyr_Fname NVARCHAR2(20),
Plyr_Sname NVARCHAR2(20),
Plyr_DOB date,
Plyr_Height DOUBLE,
Plyr_Weight double,
Plyr_position NVARCHAR2(20),
Plyr_experience int,
Team_ID INT NOT NULL,
CONSTRAINT fk_Team FOREIGN KEY (Team_ID) references Team(Team_ID)

);


Error report -
SQL Error: ORA-00905: missing keyword
00905. 00000 -  "missing keyword"
*Cause:
*Action:

这是我指的团队"表:

CREATE TABLE Team(
Team_ID int NOT NULL PRIMARY KEY,
Team_Name NVARCHAR2(50),
Team_Homecourt nvarchar2(50)
);

推荐答案

您可以尝试使用NUMBER (precision, scale)代替double.所以尝试这样的事情:

Instead of double you can try to use NUMBER (precision, scale). So try something like this:

CREATE TABLE Player(
Plyr_ID int NOT NULL PRIMARY KEY,
Plyr_Fname NVARCHAR2(20),
Plyr_Sname NVARCHAR2(20),
Plyr_DOB date,
Plyr_Height NUMBER(7,2),    --Change as per your requirement.
Plyr_Weight NUMBER(7,2),
Plyr_position NVARCHAR2(20),
Plyr_experience int,
Team_ID INT NOT NULL,
CONSTRAINT fk_Team FOREIGN KEY (Team_ID) references Team(Team_ID)

);

注意:double precision是ANSI支持的数据类型,而NUMBER是Oracle内置数据类型

NOTE: double precision is ANSI-supported datatypes whereas NUMBER is Oracle built-in datatypes

因此,如果您愿意,可以坚持使用精度为:

So if you want you can stick to double using precision as:

CREATE TABLE Player(
Plyr_ID int NOT NULL PRIMARY KEY,
Plyr_Fname NVARCHAR2(20),
Plyr_Sname NVARCHAR2(20),
Plyr_DOB date,
Plyr_Height DOUBLE PRECISION,
Plyr_Weight DOUBLE PRECISION,
Plyr_position NVARCHAR2(20),
Plyr_experience int,
Team_ID INT NOT NULL,
CONSTRAINT fk_Team FOREIGN KEY (Team_ID) references Team(Team_ID)
);

这篇关于创建表-SQL错误:ORA-00905:缺少关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 15:57