David Barron <david.barron@xxxxxxxxxx> writes: > If, for example, table a has a constraint that references rows in table b, table b has to be restored first, but pg_dump doesn't take that into account. Yes it does: it doesn't restore foreign key constraints until after all the data is loaded. What I suspect is that by "constraint" you mean some handmade hack like a trigger that looks at other tables. But without details about what you're doing, it's hard to recommend solutions. regards, tom lane