Partial data dump/restore
TweetPosted on Tuesday Mar 11, 2014 at 03:45PM in Technology
dump data
hogedb=# copy (select * from hogetable where basedate between '20070101' and '20070131') TO '/tmp/1month.sql'; COPY 561368 hogedb=#
dump schema
pg_dump --schema-only -t hogetable hogedb > /tmp/1month.ddl
restore schema
hogedb=# \i /tmp/1month.ddl SET SET SET SET SET SET SET SET CREATE TABLE ALTER TABLE ALTER TABLE ALTER TABLE CREATE INDEX CREATE INDEX hogedb=#
restore data
hogedb=# copy hogetable from '/tmp/1month.sql'; COPY 561368 hogedb=#
References
Tags: postgres