Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postgres dump with inserts but without copy actions

I am trying to dump my database.

For reasons I can't go into detail here, I am unable to use the "Copy" function. This means that the insert statements have to be "pure" insert. However, I am not sure how to reflect this in my dump.

Currently, this is my dump command:

 pg_dump -U myUser --column-inserts --data-only  -h localhost my_db> backup

Can anyone tell me how i might get the insert statements without the Copy function?

like image 848
Marc Rasmussen Avatar asked Feb 25 '26 04:02

Marc Rasmussen


1 Answers

The documentation of pg_dumps tells us this:

--inserts

Dump data as INSERT commands (rather than COPY). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-PostgreSQL databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!