开发者

How to backup some tables with data and some tables only schema PostgreSQL

I want to dump a database.

I have three tables:

table1 table2 table3

From table1 i want the schema plus data.

From table2 and table3 i just want开发者_如何学运维 the schema.

How do i do that?


To get data from just a few tables:

pg_dump myDatabase --inserts -a -t table1 -t table2 > backup.sql;

pg_dump myDatabase --inserts -a -t seq1 -t seq2 > backupSequences.sql;

Parameters descriptions:

-a, --data-only dump only the data, not the schema

-t, --table=TABLE dump the named table(s) only

--inserts dump data as INSERT commands, rather than COPY

This is what i wanted :)

Thanks all!


Use pg_dump, which has both schema-only and schema + data output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜