Q:

Database Insertion Fails Because Of Foreign Key Constraint

I'm working on database migration program and I'm trying to migrate one database to the another database whoose tables are already created. To be more specific I have two database with almost same tables and the one is full and the other one is empty. My problem is migration table values is proccessing alphabeticly. Some tables have foreign key and if these tables are come before alphabeticly from foreign key tables ,I cannot inser values. Is there any way to disable foreign key check on java or postgresql. Any help would be great.

A:

If I am right, there is no possibility to disable fk on postgresql. As @mcfinnigan said, you can drop fk before starting insertion or you can recreate contraints with DEFERRABLE key. Refer to postgresql CREATE TABLE documentation.
DEFFERABLE means, fk will not be checked until transaction finished.

