From: | Xiaobo Gu <guxiaobo1982(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: question about \encoding option of psql |
Date: | 2011-12-16 06:33:03 |
Message-ID: | CACOCgcnLv14ePOOxRAnihFhRirm4ikSv-esh=8GDu6nnLRaqKQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Adrian,
I am on the Windows platform, how should I paste the command line.
Regards,
Xiaobo Gu
On Thu, Dec 15, 2011 at 10:44 PM, Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> wrote:
> On Wednesday, December 14, 2011 10:12:40 pm Xiaobo Gu wrote:
>> Hi,
>>
>> I know \encoding is a meta command to set client encoding on psql
>> prompt, but how can I set it inside the psql command line which will
>> be called inside shell scripts,
>>
>> psql -h 192.168.72.7 -U gpadmin -w -d miner_demo -c"\copy demo.store
>> to 'd:\store.csv' with csv header"
>>
>>
>> How can I set the encoding for the export csv file?
>
>
>
> http://www.postgresql.org/docs/9.0/interactive/app-psql.html
> -c command
> --command command
>
> Specifies that psql is to execute one command string, command, and then exit.
> This is useful in shell scripts. Start-up files (psqlrc and ~/.psqlrc) are
> ignored with this option.
>
> command must be either a command string that is completely parsable by the
> server (i.e., it contains no psql-specific features), or a single backslash
> command. Thus you cannot mix SQL and psql meta-commands with this option. To
> achieve that, you could pipe the string into psql, like this: echo '\x \\ SELECT
> * FROM foo;' | psql. (\\ is the separator meta-command.)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>
> If the command string contains multiple SQL commands, they are processed in
> a single transaction, unless there are explicit BEGIN/COMMIT commands included
> in the string to divide it into multiple transactions. This is different from the
> behavior when the same string is fed to psql's standard input.
>
>
>>
>> Regards,
>>
>> Xiaobo Gu
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Igor Neyman | 2011-12-16 15:30:34 | Re: Vacuum and Large Objects |
Previous Message | Patrick Kevin McCaffrey | 2011-12-16 06:12:48 | New User: PostgreSQL Setup - "The Program 'postgress' is needed by initdb but was not found in the same directory..." |