I need to load 50+ tables from scratch which have bunch of FK constraints, for now I just drop all FKs, load tables in any order (my data is compliant with all FKs) , then ADD FKs. What is other way to do this, order for FK definition is critical as I can see, so let say looking at my sample, is this the right way to do ?
ALTER TABLE CUST ADD CONSTRAINT CUS_BatchID_FK FOREIGN KEY (BatchID) REFERENCES Batch(BatchID);
ALTER TABLE CYCLE ADD CONSTRAINT CL_BatchID_FK FOREIGN KEY (BatchID) REFERENCES Batch(BatchID);
ALTER TABLE QOUTE ADD CONSTRAINT QT_BatchID_FK FOREIGN KEY (BatchID) REFERENCES Batch(BatchID);
ALTER TABLE MD_LOC ADD CONSTRAINT MLOC_FK FOREIGN KEY (LOC_ID) REFERENCES LOC(LOC_ID);
ALTER TABLE CUST ADD CONSTRAINT CUST_PROV_FK FOREIGN KEY (PROV_ID) REFERENCES PROVIDER(PROV_ID);
ALTER TABLE REFER ADD CONSTRAINT RF_CUST_ID_FK FOREIGN KEY (CUST_ID) REFERENCES CUST(CUST_ID);
/*--------------------
1. load Batch
2. load LOC
2a. Load MD_LOC
3. load PROVIDER
3a. load CUST
.....
I.e I'm loaded tables first without FK, then go in sequence, I tested it for couple of tables and it works, just want to confirm if anything might be missing before I go with the rest of tables.