Re: COPY is not working - Mailing list pgsql-hackers

From Takahiro Itagaki
Subject Re: COPY is not working
Date
Msg-id 20100430151307.94E0.52131E4D@oss.ntt.co.jp
Whole thread Raw
In response to Re: COPY is not working  (Jaime Casanova <jcasanov@systemguards.com.ec>)
Responses Re: COPY is not working
List pgsql-hackers
Jaime Casanova <jcasanov@systemguards.com.ec> wrote:

> ah! this is because COPY doesn't follow inherited tables... should it?

Yes. You can use "COPY (SELECT * FROM a) TO " instead to copy all tuples.

http://developer.postgresql.org/pgdocs/postgres/sql-copy.html
| COPY can only be used with plain tables, not with views.
| However, you can write COPY (SELECT * FROM viewname) TO .... 

Should we add "or parent tables" after "not with views"?
To be exact, it would be "'COPY a parent table TO' only copies
tuples in the parent table and does not copy inherited child tables".


regression=# CREATE TABLE a (aa integer);
CREATE TABLE
regression=# CREATE TABLE b () INHERITS (a);
CREATE TABLE
regression=# INSERT INTO b VALUES(32), (56);
INSERT 0 2
regression=# select * from a;aa
----3256
(2 rows)

regression=# COPY a TO '/tmp/copy_test';
COPY 0
regression=# COPY (SELECT * FROM a) TO '/tmp/copy_test';
COPY 2

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center




pgsql-hackers by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: COPY is not working
Next
From: Jaime Casanova
Date:
Subject: Re: COPY is not working