0
我是一個嘗試設置一些基本表的新手。我已經創建了一個名爲Customer的表,其中名爲Cust_ID的主鍵和名爲City的表稱爲Zip_Code。當我嘗試創建一個名爲Address的表並將這些PK包含爲FK時,我會得到下面的錯誤。任何幫助非常感謝,因爲已經嘗試了幾種Web解決方案下面的代碼和錯誤。謝謝,理查德。Oracle 11g SQL錯誤:ORA-00904:「CUST_ID」:無效的標識符
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:
您的「地址」表沒有列名「cust_id」或「zip_code」。您只定義了列'addr_id','addr_ln1','addr_ln2'。 –
非常感謝a_horse_with_no_name。我多麼愚蠢。這解決了它。 – user1893091