Reputation: 1811
I have an sql file(we can generate this in whatever way we want).
I want to load it fully initially, then want to update(delete, create) db based using logic.
Later, if I want to delete more, we can simply delete.
But, if we want to add more, then we need to import sql again. Before importing, I cant drop those tables because they are already foreign keys to others. So, I can only do this:
Run sql file somehow to add only non-available entries to database skipping available entries so I can skip errors ( duplicate key value violates unique ).
Upvotes: 0
Views: 171
Reputation: 23890
Import your data to a temporary table and then just use something like:
insert into real_table_name
select * from temporary_table_name
where id not in (select id from real_table_name);
Upvotes: 1