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
Post a Comment