The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.

Export Query Result to csv file

Hi,
I am trying to export my query result to csv file by using below command. When i try to execute below command, file is exporting in linux machine where the vertica was  installed 
But i just want to export file into my local machine.
Is it possible with vsql?

vsql -U test -d db_name -h 1.0.0.0 -w vertica -c "select * from export_query_result " -Aq -P footer=off -F ',' -o "/tmp/example.csv"

Can i execute above command using .NET?

Comments

  • You can install vertica client on the local machine and then using vsql export the data
  • vertica client installed in my machine.. But I am new to vertica .
    if possible Can u give detailed steps to export?
  • Hi Rajashekar

    Since you have vsql installed in your machine.You can connect to the corresponding database/cluster as shown in below example & once connected can run below command to save the output of any command in that file. This will save the file in your local machine from where you have connected.As in my case it has saved this file in this location under "C:\Users\rahul.choudhary1"

    Example:
    =======
    C:\Users\rahul.choudhary1>vsql -h 10.50.52.97 -d V701_97 -U dbadmin
    Password:
    Welcome to vsql, the Vertica Analytic Database interactive terminal.

    Type:  \h or \? for help with vsql commands
           \g or terminate with semicolon to execute query
           \q to quit

    Warning: Console code page (437) differs from Windows code page (1252)
             8-bit characters may not work correctly. See vsql reference
             page "Notes for Windows users" for details.

    V701_97=> \o example.csv

    V701_97=> select * from nodes;
         node_name      |      node_id      | node_state | node_address | node_addre
    ss_family | export_address | export_address_family |                       catal
    og_path                       | node_type | is_ephemeral | standing_in_for | nod
    e_down_since
    --------------------+-------------------+------------+--------------+-----------
    ----------+----------------+-----------------------+----------------------------
    ------------------------------+-----------+--------------+-----------------+----
    -------------
     v_v701_97_node0001 | 45035996273704980 | UP         | 10.50.52.97  |
              | 10.50.52.97    | ipv4                  | /home/dbadmin/V701_97/v_v70
    1_97_node0001_catalog/Catalog | PERMANENT | f            |                 |
    (1 row)

    V701_97=> \o


    Regards
    Rahul

  • ya, I got it,
    Thank you very much for your reply :-)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.