In Oracle SQL, SQL Developer: I am trying to create two tables, each which has a foreign key that references the other table's primary key.
Using my logic, I cannot set the foreign key references because the other table does not yet exist.
Here's a general idea of how I'm structuring it:
CREATE TABLE table1
(
column1 datatype PRIMARY KEY NOT NULL,
column2 datatype NOT NULL,
column3 datatype NOT NULL,
CONSTRAINT fk_keyname
FOREIGN KEY (colmn3)
REFERENCES otherTable (column3)
);
CREATE TABLE table2
(
column1 datatype PRIMARY KEY NOT NULL,
column2 datatype NOT NULL,
column3 datatype NOT NULL,
CONSTRAINT fk_keyname2
FOREIGN KEY (colmn3)
REFERENCES otherTable2 (column3)
);
I'm getting an error
ORA-00942: table or view does not exist
I have fixed this before by creating the parent table first, but since they both reference each other I'm at a loss as what I need to do here because the MUST REFERENCE EACH OTHER in this particular case.