Search Postgresql Archives

Re: Is it necessary to have index for child table in following case?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/03/2010 06:59 PM, Yan Cheng Cheok wrote:
> PQexec(Database::instance().getConnection(), "copy unit_1 from
> stdin"); // | serial | int | int /* But I just do not want to put
> 9999 as serial. I want it to be auto-increment. However, I have no
> idea how to make serial auto-increment, without using INSERT. */ 
> PQputline(Database::instance().getConnection(),"9999\t1\t888\n"); 
> PQputline(Database::instance().getConnection(),"\\.\n"); 
> PQendcopy(Database::instance().getConnection());

You really need to get up close and personal with the fine manual.

See:
-----------
http://developer.postgresql.org/pgdocs/postgres/sql-copy.html

Specifically:
-----------
Synopsis

COPY table_name [ ( column [, ...] ) ]
    FROM { 'filename' | STDIN }
    [ [ WITH ] ( option [, ...] ) ]

Example:
-----------
regression=# create table foo(f1 serial, f2 text);
NOTICE:  CREATE TABLE will create implicit sequence "foo_f1_seq" for
serial column "foo.f1"
CREATE TABLE
regression=# copy foo (f2) from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> hello
>> world
>> \.

regression=# select * from foo;
 f1 |  f2
----+-------
  1 | hello
  2 | world
(2 rows)

HTH,

Joe


Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux