database - How to extract a table from a *.dump file into a CSV -


i have *.dump file (postgresql dump) , output my_table my_table.csv. there better way pg_restore -t my_table db.dump > my_table.txt , writing script create csv output?

the output pg_restore --data-only -t my_table db.dump is tab-separated headerless tabulated text comments , few commands. script mangle csv tool perl or awk pretty simple.

that said, would:

  • restore table temporary database created purpose. if table depends on custom types, functions, sequences, etc need restore them too.

  • in psql, \copy the_table 'some_file.csv' (format csv, header on)

this way can control representation of nulls , lots more.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -