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,aligned, html, or latex)
pset format unaligned
-- setup field separetor character
pset fieldsep '|'
-- print only the tuples
pset tuples_only
-- store the result of the query into a file
o /tmp/test.csv
-- run query
SELECT * FROM HD_BANCO;
-- read file from operational system
! cat /tmp/test.csv
I hope that was helpful