简体   繁体   中英

SQL ORACLE - "Table or view does not exist"

CREATE TABLE Order_Item
(
    Tree_ID VARCHAR(30) PRIMARY KEY
    REFERENCES Tree(ID),
    Order_ID VARCHAR(30) NOT NULL,
    FOREIGN KEY (Order_ID) REFERENCES Order_Form(Order_ID)
);


CREATE TABLE Tree
(
    ID VARCHAR(30) PRIMARY KEY,
    Roottype VARCHAR(30) NOT NULL,
    FOREIGN KEY (Roottype) REFERENCES Rootstock(Rootstocktype),
    Variety VARCHAR(60) NOT NULL,
    FOREIGN KEY (Variety) REFERENCES Variety(Name),
    Age NUMBER(9) NOT NULL,
    CHECK (Age >= 0),
    Pot_Size NUMBER(9) NOT NULL,
    CHECK (Pot_Size >= 0),
    Price NUMBER(9) NOT NULL,
    CHECK (Price >= 0),
    Available_On VARCHAR(100) NOT NULL
);

Can someone explain to me why im getting this error code? Thank You

Oracle checks if all objects you are creating exists. When you try to create table Order_Item, your schema is referencing another table that you are creating later. The solution is create first tables without references and finally most complex tables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM