Oracle 11g SQL错误:ORA-00904:" CUST_ID":无效的标识符

时间:2014-05-04 10:23:02

标签: oracle11g

我是一个试图设置一些基本表格的新手。我已经使用名为Cust_ID的主键创建了一个表名Customer,并创建了一个名为City with PK的表,名为Zip_Code。当我尝试创建一个名为Address的表并将这些PK包含为FK时,我得到以下错误。任何帮助非常感谢已经尝试了几个Web解决方案。代码和错误如下。谢谢,理查德。

CREATE TABLE ADDRESS
( ADDR_ID INTEGER NOT NULL,
Addr_Ln1 VARCHAR2(100) NOT NULL,    
Addr_Ln2 VARCHAR2(100) NOT NULL,    
CONSTRAINT ADDRESS_PK PRIMARY KEY (ADDR_ID),
 CONSTRAINT fk_customer FOREIGN KEY(Cust_ID) REFERENCES CUSTOMER (Cust_ID) ON DELETE CASCADE,
 CONSTRAINT fk_city FOREIGN KEY (Zip_Code) REFERENCES CITY (Zip_Code) ON DELETE CASCADE
);

这会出现以下错误:

Error starting at line : 1 in command -
CREATE TABLE ADDRESS
( ADDR_ID INTEGER NOT NULL,
Addr_Ln1 VARCHAR2(100) NOT NULL,    
Addr_Ln2 VARCHAR2(100) NOT NULL,    
CONSTRAINT ADDRESS_PK PRIMARY KEY (ADDR_ID),
 CONSTRAINT fk_customer FOREIGN KEY(Cust_ID) REFERENCES CUSTOMER (Cust_ID) ON DELETE CASCADE,
 CONSTRAINT fk_city FOREIGN KEY (Zip_Code) REFERENCES CITY (Zip_Code) ON DELETE CASCADE
)
Error at Command Line : 6 Column : 37
Error report -
SQL Error: ORA-00904: "CUST_ID": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:

1 个答案:

答案 0 :(得分:0)

在您的create语句中检查您的脚本为“Cust_ID”列。 您只创建了三列(ADDR_ID,Addr_Ln1,Addr_Ln2)