Saving a vertica query to a file from the vsql prompt
search cancel

Saving a vertica query to a file from the vsql prompt

book

Article ID: 11913

calendar_today

Updated On:

Products

CA Infrastructure Management CA Performance Management - Usage and Administration

Issue/Introduction



What is the syntax to save a vertica query to a file when run from the vsql prompt and without logging into adminTools?

Environment

CAPM 2.x

Resolution

To save a vertica query to a file when run from the vsql prompt and without logging into adminTools you can do the following:

 

1. Log on to the data repository

2. Change to the dradmin user (su - dradmin)

3. cd /opt/vertica/bin

4. Run the following query:

./vsql -U<user> -w<password> -c 'query;' > /tmp/filename.txt

 

Example:

./vsql -Udradmin -wdbpass -c 'select database_name from databases;' > /tmp/database.txt

 

Output: 

cat /tmp/database.txt

 database_name

---------------

 drdata

(1 row)