为什么这些SQL代码会一直显示IDENTIFIER错误?

时间:2015-11-10 18:16:07

标签: sql oracle

create table EMPLOYEE
(Emp_id VARCHAR(30) not null,
Emp_fname varchar(20),
Emp_mname varchar(20),
Emp_lname varchar(20),
Emp_SSN varchar(20),
"position" varchar(30),
Emp_Straddr1 varchar(100),
Emp_Straddr2 varchar(100),
Emp_City varchar(100),
Emp_State varchar(100),
Emp_Zip char(5),
Emp_Phone varchar(20),
Supervisor VARCHAR(30) not null,
constraint pk_employee primary key (Emp_id),
constraint fk_employeehassupervisor foreign key (Supervisor)     references EMPLOYEE(Emp_id));

create table VINEYARD
(Vineyard_Name VARCHAR(20) not null,
"Location" varchar(30),
"Size" number(4,2),
Emp_id VARCHAR(5) not null,
constraint pk_vineyard primary key (Vineyard_Name),
constraint fk_vineyardhasmanager foreign key (Emp_id) references EMPLOYEE(Emp_id));

create table GRAPE
(Grape_Name varchar(30) not null,
JuiceConversionRatio number(5,2),
WineStorageRequirement varchar(30),
WineAgingRequirement varchar(1),
constraint pk_grape primary key (Grape_Name));



alter table VINEYARD 
modify (Vineyard_Name VARCHAR(20));

create table GRAPE_HARVEST_HISTORY
(Vineyard_Name varchar(20) not null,
Grape_Name varchar(30) not null,
"Year" YEAR NOT NULL,
Weight number(4,2),
RipenessDegree number(5,2),
constraint pk_grape_harvest_history primary key      (Vineyard_Name,"Year"),
constraint fk_grape_harvest_historyhasvineyard foreign key     (Vineyard_Name) references VINEYARD(Vineyard_Name),
constraint fk_grape_harvest_historyhasgrape foreign key (Grape_Name)      references GRAPE(Grape_Name));

这里是ORACLE SQL中的确切显示。

表EMPLOYEE创建。

表VINEYARD创建。

表格GRAPE已创建。

表VINEYARD改变了。

从命令行中的第38行开始出错 - 创建表GRAPE_HARVEST_HISTORY (Vineyard_Name varchar(20)not null, Grape_Name varchar(30)不为null, “年份”年份不是空的, 重量数(4,2), 成熟度数(5,2), 约束pk_grape_harvest_history主键(Vineyard_Name,“Year”), 约束fk_grape_harvest_historyhasvineyard外键(Vineyard_Name)引用VINEYARD(Vineyard_Name), 约束fk_grape_harvest_historyhasgrape外键(Grape_Name)引用GRAPE(Grape_Name)) 错误报告 - SQL错误:ORA-00972:标识符太长 00972. 00000 - “标识符太长” *原因:指定了超过30个字符的标识符。 *动作:最多指定30个字符。

1 个答案:

答案 0 :(得分:2)

约束名称太长,最多30个字符,这两个字符长度为32和34个字符

fk_grape_harvest_historyhasvineyard fk_grape_harvest_historyhasgrape