Export data into cvs format from Vertica using the vsql Meta-Commands
Just to play around and maybe someday this can be useful to any of you we will see how can we export a result set from Vertica into a csv file using Vsql Meta-Commands.
What are the meta-commands ?
“Anything you enter in vsql that begins with an unquoted backslash is a vsql meta-command that is processed by vsql itself. These commands help make vsql more useful for administration or scripting. Meta-commands are more commonly called slash or backslash commands.”
Let’s get on with our simple example:
-- setup border properties
pset border 1 Border style is 1
-- setup output format(unaligned,<code>aligned</code>, <code>html</code>, or <code>latex</code>)
pset format unaligned
-- setup field separetor character
pset fieldsep '|'
-- print only the tuples
-- store the result of the query into a file
-- run query
SELECT * FROM HD_BANCO;
-- read file from operational system
! cat /tmp/test.csv
I hope that was helpful