Recently, I was in a situation where I had to move data from an old version of a database to a newer version of the same database. The structure of the database had changed slightly. I was trying to figure out what data to move first. I wanted to move data that was referenced before moving the data referencing it in order to avoid foreign key contraints errors. It was getting quite complicated to find out what to move first when I came accross interesting scripts to disable/re-enable triggers and constraints. Once these were disabled, it did not matter anymore what data I was moving first. After all the data was moved, I simply had to re-enable the triggers and constraints. By the way, I used the two bottom scripts (Figure 2 and figure 3).