Jaime Casanova <jcasa...@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
----
 32
 56
(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



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to