Skip navigation
10379 Views 5 Replies Latest reply: Jul 22, 2011 4:10 AM by Jojo Thomas RSS
Currently Being Moderated

Sep 7, 2010 6:09 PM

nzsql \copy

nzsql has a command called \copy

what is the syntax to dump the contents of a query to an output file using \copy

 

thanks.

  • David Shuttleworth Active Enzee 270 posts since
    May 14, 2008
    Currently Being Moderated
    1. Sep 8, 2010 4:21 AM (in response to Vijay Nori)
    Re: nzsql \copy

    The \copy in nzsql runs a SQL COPY statement - e.g.

     

    \copy TABLE1 to '/home/usr/daves/table1.out';

     

    but see database users guide for the full syntax of this - and also not the warning about EXTERNAL TABLEs being the preferred method for this type of operation.

     

    D.

  • Joey Foley New Enzee 35 posts since
    Oct 23, 2006
    Currently Being Moderated
    2. Sep 8, 2010 9:49 AM (in response to Vijay Nori)
    Re: nzsql \copy

    I think you might want to try the \o [file] command.

    That will redirect query output to a file.

  • ulab New Enzee 59 posts since
    Jul 1, 2011
    Currently Being Moderated
    3. Jul 21, 2011 3:43 AM (in response to Joey Foley)
    Re: nzsql \copy

    i tried using COPY but  below is the error am getting..

     

    ED(ADMIN)=> \copy test_nz_proc_ct to 'bji.out'
    ERROR:  Table 'test_nz_proc_ct' does not exist
    \copy: ED(ADMIN)=> \d test_nz_proc_ct
                        Table "TEST_NZ_PROC_CT"
    Attribute  |         Type          | Modifier | Default Value
    ------------+-----------------------+----------+---------------
    X          | INTEGER               |          |
    Y          | CHARACTER VARYING(10) |          |
    Z          | CHARACTER VARYING(10) |          |
    OPERATION$ | CHARACTER VARYING(2)  |          |
    Distributed on hash: "X"

  • ankur New Enzee 10 posts since
    Apr 12, 2010
    Currently Being Moderated
    4. Jul 21, 2011 11:04 AM (in response to Vijay Nori)
    Re: nzsql \copy

    Netezza do have COPY command to move the data from/to Table to/from File but they do not recommend it. They recommends NZLOAD/NZSQL to do the same thing.

     

    We normally use to :

    nzsql -u<user name> -p<password> -d<> -h<host> -A -q -t -f test.sql -o test.out -F"  "

     

    Please have a look at the User Guide for more information on COPY Command.

  • Jojo Thomas Active Enzee 208 posts since
    Mar 1, 2011
    Currently Being Moderated
    5. Jul 22, 2011 4:10 AM (in response to ulab)
    Re: nzsql \copy

    The error is quite self explanatory I did suppose. Have you ensured you are in teh right database, and that '\d  test_nz_proc_ct' works.

More Like This

  • Retrieving data ...

Bookmarked By (0)