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

From: Joe Conway <mail(at)joeconway(dot)com>
To: Yan Cheng Cheok <yccheok(at)yahoo(dot)com>
Cc: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>, pgsql-general(at)postgresql(dot)org
Subject: Re: Is it necessary to have index for child table in following case?
Date: 2010-02-04 03:46:43
Message-ID: 4B6A4323.4060607@joeconway.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sim Zacks 2010-02-04 06:31:55 Re: Shall I apply normalization in the following case?
Previous Message Yan Cheng Cheok 2010-02-04 02:59:59 Re: Is it necessary to have index for child table in following case?