开发者

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

开发者 https://www.devze.com 2023-03-23 18:55 出处:网络
I want to dump a database. I have three tables: table1 table2 table3 From table1 i want the schema plus data.

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

精彩评论

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