Sep 7, 2010 6:09 PM
nzsql \copy
-
Like (0)
nzsql has a command called \copy
what is the syntax to dump the contents of a query to an output file using \copy
thanks.
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.
I think you might want to try the \o [file] command.
That will redirect query output to a file.
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"
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.
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.

