gotchasqlMinor
difference between pg_dump command's --column-insert and --attribute-insert
Viewed 0 times
pg_dumpinsertcolumndifferencebetweenattributeandcommand
Problem
Background:
I'm trying to create a dump file that only contains the data in my database. I would like it to create the data with the INSERT command.
In reading the manual, (http://www.postgresql.org/docs/9.2/static/app-pgdump.html#PG-DUMP-EXAMPLES) i see that I can use either
It wasn't clear from the manual what the difference is. So I tried both and did a diff on the files.
There are differences and I'm wondering why.
Can someone tell me what the difference is between these two commands?
Here's the full command I'm running:
and :
Any tips would be appreciated. In the meantime, I'm going to dig in and see what's different between these two files... why certain records are included and others not.
Thanks.
I'm trying to create a dump file that only contains the data in my database. I would like it to create the data with the INSERT command.
In reading the manual, (http://www.postgresql.org/docs/9.2/static/app-pgdump.html#PG-DUMP-EXAMPLES) i see that I can use either
- --column-insert
- --attribute-insert
It wasn't clear from the manual what the difference is. So I tried both and did a diff on the files.
There are differences and I'm wondering why.
Can someone tell me what the difference is between these two commands?
Here's the full command I'm running:
pg_dump -a --column-inserts -U postgres testdb > /tmp/test_data_as_inserts2.sqland :
pg_dump -a --attribute-inserts -U postgres testdb > /tmp/test_data_as_inserts.sqlAny tips would be appreciated. In the meantime, I'm going to dig in and see what's different between these two files... why certain records are included and others not.
Thanks.
Solution
They are the same. Check the documentation (where they are mentioned together):
Dump data as INSERT commands with explicit column names (
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.
--column-inserts --attribute-inserts Dump data as INSERT commands with explicit column names (
INSERT INTO table (column, ...) VALUES ...). This will make restoration veryslow; 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.
Context
StackExchange Database Administrators Q#70097, answer score: 7
Revisions (0)
No revisions yet.