Re: Is it necessary to have index for child table in following case? - Mailing list pgsql-general

From Joe Conway
Subject Re: Is it necessary to have index for child table in following case?
Date
Msg-id 4B6A4323.4060607@joeconway.com
Whole thread Raw
In response to Re: Is it necessary to have index for child table in following case?  (Yan Cheng Cheok <yccheok@yahoo.com>)
List pgsql-general
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

pgsql-general by date:

Previous
From: Yan Cheng Cheok
Date:
Subject: Re: Is it necessary to have index for child table in following case?
Next
From: Sim Zacks
Date:
Subject: Re: Shall I apply normalization in the following case?