Skip to main content

How do I unload a Vertica table to a flat file?


Cece_Shetline_V
How do I use the COPY command to unload a Vertica table to a flat file?

4 replies

Forum|alt.badge.img+2
  • Participating Frequently
  • April 27, 2013
You don't need to use a copy command to export data to a text file. You can export the data using vsql such as \o /tmp/export_data.txt select * from table; \o now the data is exported in export_data.txt or directly from Linux you can do # vsql -c "select * from table;" > /tmp/export_data.txt. Check the documentation for details in how to change delimiter, replace nulls, etc. Hope this helps, Eugenia

Cece_Shetline_V
Thank you!! That really helps!!

Forum|alt.badge.img+2
  • Participating Frequently
  • April 27, 2013
Can you say more about your usecase for export to a flat file?

Steve_O_Hara
In our experience the only reliable way to get data out of Vertica in CSV or similar is to use a client (ODBC/JDBC) tool. VSQL works for most situations except when you have line breaks in your data etc. Produces data that can't be re-loaded.