VSQL extract data into file

Hey there! So you use Vertica and vsql to interact with your tables. Ever had those times when you wanted to take stuff from your table and paste it into Microsoft Excel for sending it off to someone not so technically acquainted with Vertica?
You could write a script to do that for you. But if you just had to do it within a vsql session you also have options to do it.

Well I have had quite a lot of such scenarios. So I decided why not explore some features of vsql client.
When you are in vsql, all you have to do is the following:
vsql> \pset format unaligned
vsql> \pset fieldsep ','
vsql> \o /home/user/username/outputfilename.extension
vsql> \pset footer
vsql> select * from mytable where field='myvalue';
And you have your file already!
Then all you have to do is learn to transform text into columns.
I don't think I have to help you with that.

Comments